Interface ValidationAdapter<T>

Type Parameters:
T - The type of value to be validated
All Known Implementing Classes:
AbstractConstraintAdapter, ContainerAdapter, PrimitiveAdapter
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ValidationAdapter<T>
This interface defines a set of validation methods for validating a value based on specific rules. The methods in this interface allow for executing validations, composing validation adapters, and checking validation groups.
  • Method Details

    • validate

      boolean validate(T value, ValidationRequest req, String propertyName)
      Execute validations for the given value.
      Parameters:
      value - The value to be validated
      req - The validation request containing group/locale/violation information
      propertyName - The name of the property being validated
      Returns:
      true if validation should continue, false otherwise
    • validate

      default boolean validate(T value, ValidationRequest req)
      Execute validations for the given value
      Parameters:
      value - The value to be validated
      req - The validation request containing group/locale/violation information
      Returns:
      true if validation should continue, false otherwise
    • primitive

      default ValidationAdapter.Primitive primitive()
      Return a primitive adapter. Supports int, long with Range, Min, Max, Positive.
    • list

      default ContainerAdapter<T> list()
      Create an adapter for validating a list of values.
      Returns:
      The adapter for list validation
    • mapKeys

      default ContainerAdapter<T> mapKeys()
      Create an adapter for validating map keys.
      Returns:
      The adapter for map key validation
    • mapValues

      default ContainerAdapter<T> mapValues()
      Create an adapter for validating map values.
      Returns:
      The adapter for map value validation
    • array

      default ContainerAdapter<T> array()
      Create an adapter for validating an array.
      Returns:
      The adapter for array validation
    • optional

      default ContainerAdapter<T> optional()
      Create an adapter for validating an optional value.
      Returns:
      The adapter for optional value validation
    • andThen

      default ValidationAdapter<T> andThen(ValidationAdapter<? super T> after)
      Compose this validation adapter with another adapter by applying the validations in sequence.
      Parameters:
      after - The validation adapter to be applied after this adapter
      Returns:
      The composed validation adapter
      Throws:
      NullPointerException - if after is null
    • checkGroups

      default boolean checkGroups(Set<Class<?>> adapterGroups, ValidationRequest request)
      Check if the validation request groups are empty or match any of the adapter's configured groups.
      Parameters:
      adapterGroups - The groups configured for this adapter
      request - The validation request containing the groups to be checked
      Returns:
      true if the groups match or if the validation request groups are empty, false otherwise