Interface TypeValidation


@Contract public interface TypeValidation
A validator service.

Validator allows programmatic validation of instances, properties and values.

  • Method Details

    • validate

      <T> ValidationResponse validate(Class<T> type, T object)
      Validate an object that is annotated with Validation.Validated.
      Type Parameters:
      T - type of the validated object, i.e. the type annotated with Validation.Validated
      Parameters:
      type - type annotated with Validation.Validated to use for validation of the provided object
      object - object instance to validate
      Returns:
      validator response
      Throws:
      IllegalArgumentException - in case the type is not validated
    • check

      <T> void check(Class<T> type, T object)
      Validate an object that is annotated with Validation.Validated.
      Type Parameters:
      T - type of the validated object, i.e. the type annotated with Validation.Validated
      Parameters:
      type - type annotated with Validation.Validated to use for validation of the provided object
      object - object instance to validate
      Throws:
      IllegalArgumentException - in case the type is not validated
      ValidationException - in case the type is not validated or validation fails
    • validate

      <T> ValidationResponse validate(Class<T> type, T object, String propertyName)
      Validate a specific property of an object that is annotated with Validation.Validated.

      A property is considered to be one of the following:

      • A record component with constraint annotation(s)
      • A method with constraint annotation(s) that matches getter pattern - non-void return type, no parameters
      • Non-private field with constraint annotation(s)
      Type Parameters:
      T - type of the validated object, i.e. the type annotated with Validation.Validated
      Parameters:
      type - type annotated with Validation.Validated to use for validation of the provided object
      object - object instance to validate
      propertyName - name of the property
      Returns:
      validator response
      Throws:
      IllegalArgumentException - in case the type is not validated
    • check

      <T> void check(Class<T> type, T object, String propertyName)
      Validate a specific property of an object that is annotated with Validation.Validated.

      A property is considered to be one of the following:

      • A record component with constraint annotation(s)
      • A method with constraint annotation(s) that matches getter pattern - non-void return type, no parameters
      • Non-private field with constraint annotation(s)
      Type Parameters:
      T - type of the validated object, i.e. the type annotated with Validation.Validated
      Parameters:
      type - type annotated with Validation.Validated to use for validation of the provided object
      object - object instance to validate
      propertyName - name of the property
      Throws:
      IllegalArgumentException - in case the type is not validated
      ValidationException - in case the type is not validated or validation fails
    • validateProperty

      ValidationResponse validateProperty(Class<?> type, String propertyName, Object value)
      Validate a value against a specific property of an object that is annotated with Validation.Validated.

      A property is considered to be one of the following:

      • A record component with constraint annotation(s)
      • A method with constraint annotation(s) that matches getter pattern - non-void return type, no parameters
      • Non-private field with constraint annotation(s)
      Parameters:
      type - type annotated with Validation.Validated
      propertyName - name of the property
      value - value to check
      Returns:
      validator response
      Throws:
      IllegalArgumentException - in case the type is not validated
    • checkProperty

      void checkProperty(Class<?> type, String propertyName, Object value)
      Validate a value against a specific property of an object that is annotated with Validation.Validated.

      A property is considered to be one of the following:

      • A record component with constraint annotation(s)
      • A method with constraint annotation(s) that matches getter pattern - non-void return type, no parameters
      • Non-private field with constraint annotation(s)
      Parameters:
      type - type annotated with Validation.Validated
      propertyName - name of the property
      value - value to check
      Throws:
      IllegalArgumentException - in case the type is not validated
      ValidationException - in case the type is not validated or validation fails