Interface ValidationContext


public interface ValidationContext
Context used to lookup validation adapters and create validation requests.
  • Method Details

    • adapter

      <T> ValidationAdapter<T> adapter(Class<T> cls)
      Return the adapter for the given type.
      Type Parameters:
      T - The type this adapter validates
      Parameters:
      cls - The class for which the adapter is requested
      Returns:
      The validation adapter for the given type
    • adapter

      <T> ValidationAdapter<T> adapter(Type type)
      Return the adapter for the given type.
      Type Parameters:
      T - The type this adapter validates
      Parameters:
      type - The type for which the adapter is requested
      Returns:
      The validation adapter for the given type
    • adapter

      <T> ValidationAdapter<T> adapter(Class<? extends Annotation> cls, Map<String,Object> attributes)
      Return the constraint adapter for the given annotation with attributes.
      Type Parameters:
      T - The type this adapter validates
      Parameters:
      cls - The annotation class
      attributes - The attributes associated with the annotation
      Returns:
      The validation adapter for the given annotation with attributes
    • adapter

      <T> ValidationAdapter<T> adapter(Class<? extends Annotation> cls, Set<Class<?>> groups, String message, Map<String,Object> attributes)
      Return the constraint adapter for the given annotation with attributes. Used for adapters that combine multiple annotation adapters.
      Type Parameters:
      T - The type this adapter validates
      Parameters:
      cls - The class representing the annotation type
      groups - The validation groups associated with the annotation
      message - The error message associated with the annotation
      attributes - The attributes associated with the annotation
      Returns:
      The validation adapter for the given annotation with attributes
    • noop

      <T> ValidationAdapter<T> noop()
      Return a no-op adapter.
      Type Parameters:
      T - The type this adapter validates
      Returns:
      The no-op validation adapter
    • message

      Create a message object using the annotation attribute "message".
      Parameters:
      attributes - The attributes associated with the annotation
      Returns:
      The message object
    • message

      ValidationContext.Message message(String message, Map<String,Object> attributes)
      Create a message object using the given string.
      Parameters:
      message - The error message
      attributes - The attributes associated with the annotation
      Returns:
      The message object created using the given string and annotation attributes
    • request

      ValidationRequest request(@Nullable Locale locale, List<Class<?>> groups)
      Create a validation request with the specified locale and groups.
      Parameters:
      locale - The locale for the validation request
      groups - The validation groups for the request
      Returns:
      The validation request with the specified locale and groups