@CompileStatic class ValidationService extends Object implements InitializingBean
Validation service intended to be configured and used as a singleton bean from Spring Boot application.
It creates and configures internal KlokwrkLocalValidatorFactoryBean that provides jakarta.validation.Validator interface which is used as underlying resource to which all validation requests are delegated to. To be able to use this service from Spring Boot application, minimal configuration is required that creates ValidationService bean and enables corresponding ValidationConfigurationProperties, like in the following example:@EnableConfigurationProperties(ValidationConfigurationProperties) @Configuration class SpringBootConfig { @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") @Bean ValidationService validationService(ValidationConfigurationProperties validationConfigurationProperties) { return new ValidationService(validationConfigurationProperties) } }
Type | Name and description |
---|---|
boolean |
enabled |
String[] |
messageSourceBaseNames |
jakarta.validation.Validator |
validator |
String[] |
validatorImplementationPackagesToScan |
Constructor and description |
---|
ValidationService(ValidationConfigurationProperties validationConfigurationProperties) |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
afterPropertiesSet() |
<T> |
void |
validate(T objectToValidate) Validates provided objectToValidate by delegating to the internal jakarta.validation.Validator instance. |
Validates provided objectToValidate
by delegating to the internal jakarta.validation.Validator instance.
Groovy Documentation