A validator service.
Validator allows programmatic validation of instances, properties and values.
-
Method Summary
Modifier and TypeMethodDescription<T> voidValidate an object that is annotated withValidation.Validated.<T> voidValidate a specific property of an object that is annotated withValidation.Validated.voidcheckProperty(Class<?> type, String propertyName, Object value) Validate a value against a specific property of an object that is annotated withValidation.Validated.Validate an object that is annotated withValidation.Validated.Validate a specific property of an object that is annotated withValidation.Validated.validateProperty(Class<?> type, String propertyName, Object value) Validate a value against a specific property of an object that is annotated withValidation.Validated.
-
Method Details
-
validate
Validate an object that is annotated withValidation.Validated.- Type Parameters:
T- type of the validated object, i.e. the type annotated withValidation.Validated- Parameters:
type- type annotated withValidation.Validatedto use for validation of the provided objectobject- object instance to validate- Returns:
- validator response
- Throws:
IllegalArgumentException- in case the type is not validated
-
check
Validate an object that is annotated withValidation.Validated.- Type Parameters:
T- type of the validated object, i.e. the type annotated withValidation.Validated- Parameters:
type- type annotated withValidation.Validatedto use for validation of the provided objectobject- object instance to validate- Throws:
IllegalArgumentException- in case the type is not validatedValidationException- in case the type is not validated or validation fails
-
validate
Validate a specific property of an object that is annotated withValidation.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 withValidation.Validated- Parameters:
type- type annotated withValidation.Validatedto use for validation of the provided objectobject- object instance to validatepropertyName- name of the property- Returns:
- validator response
- Throws:
IllegalArgumentException- in case the type is not validated
-
check
Validate a specific property of an object that is annotated withValidation.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 withValidation.Validated- Parameters:
type- type annotated withValidation.Validatedto use for validation of the provided objectobject- object instance to validatepropertyName- name of the property- Throws:
IllegalArgumentException- in case the type is not validatedValidationException- in case the type is not validated or validation fails
-
validateProperty
Validate a value against a specific property of an object that is annotated withValidation.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 withValidation.ValidatedpropertyName- name of the propertyvalue- value to check- Returns:
- validator response
- Throws:
IllegalArgumentException- in case the type is not validated
-
checkProperty
Validate a value against a specific property of an object that is annotated withValidation.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 withValidation.ValidatedpropertyName- name of the propertyvalue- value to check- Throws:
IllegalArgumentException- in case the type is not validatedValidationException- in case the type is not validated or validation fails
-