jakarta.validation (JSR-303) setup in a Spring
application context: It bootstraps a jakarta.validation.ValidationFactory and
exposes it through the Spring org.springframework.validation.Validator interface
as well as through the JSR-303 jakarta.validation.Validator interface and the
jakarta.validation.ValidatorFactory interface itself.
When talking to an instance of this bean through the Spring or JSR-303 Validator interfaces,
you'll be talking to the default Validator of the underlying ValidatorFactory. This is very
convenient in that you don't have to perform yet another call on the factory, assuming that
you will almost always use the default Validator anyway. This can also be injected directly
into any target dependency of type org.!
This class is also being used by Spring's MVC configuration namespace, in case of the
jakarta.validation API being present but no explicit Validator having been configured.
jakarta.validation.ValidatorFactory , jakarta.validation.Validator , jakarta.validation.Validation#buildDefaultValidatorFactory() , jakarta.validation.ValidatorFactory#getValidator()
| Modifier and Type | Class and Description |
|---|---|
| private static class | LocalValidatorFactoryBean.HibernateValidatorDelegate
Inner class to avoid a hard-coded Hibernate Validator dependency. |
| Modifier and Type | Field and Description |
|---|---|
| private ApplicationContext | |
| private Consumer | |
| private ConstraintValidatorFactory | |
| private Resource[] | |
| private MessageInterpolator | |
| private ParameterNameDiscoverer | |
| private Class | |
| private TraversableResolver | |
| private final Map | |
| private ValidationProviderResolver | |
| private ValidatorFactory |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Implements org. BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware, ApplicationContextAware etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set. |
| public void | |
| private void | |
| private void | |
| public void | destroy()
Implements org. BeanFactory on destruction of a bean.
|
| public ClockProvider | getClockProvider()
Implements jakarta. ClockProvider instance configured at
initialization time for the ValidatorFactory.
|
| public ConstraintValidatorFactory | getConstraintValidatorFactory()
Implements jakarta. ConstraintValidatorFactory instance
configured at initialization time for the
ValidatorFactory.
|
| public MessageInterpolator | getMessageInterpolator()
Implements jakarta. MessageInterpolator instance configured at
initialization time for the ValidatorFactory.
|
| public ParameterNameProvider | getParameterNameProvider()
Implements jakarta. ParameterNameProvider instance configured at
initialization time for the ValidatorFactory.
|
| public TraversableResolver | getTraversableResolver()
Implements jakarta. TraversableResolver instance configured
at initialization time for the ValidatorFactory.
|
| public Map | getValidationPropertyMap()
Allow Map access to the bean validation properties to be passed to the validation provider, with the option to add or override specific entries. |
| public Validator | getValidator()
Implements jakarta. Validator instance using the
factory defaults for message interpolator, traversable resolver
and constraint validator factory.
|
| protected void | postProcessConfiguration(Configuration<?>
the Configuration object, pre-populated with
settings driven by LocalValidatorFactoryBean's properties configuration)Post-process the given Bean Validation configuration, adding to or overriding any of its settings. |
| public void | setApplicationContext(ApplicationContext
the ApplicationContext object to be used by this object applicationContext)Implements org. |
| public void | setConfigurationInitializer(Consumer<Configuration<?>> configurationInitializer)
Specify a callback for customizing the Bean Validation |
| public void | setConstraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory)
Specify a custom ConstraintValidatorFactory to use for this ValidatorFactory. |
| public void | setMappingLocations(Resource... mappingLocations)
Specify resource locations to load XML constraint mapping files from, if any. |
| public void | setMessageInterpolator(MessageInterpolator messageInterpolator)
Specify a custom MessageInterpolator to use for this ValidatorFactory and its exposed default Validator. |
| public void | setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Set the ParameterNameDiscoverer to use for resolving method and constructor parameter names if needed for message interpolation. |
| public void | |
| public void | setTraversableResolver(TraversableResolver traversableResolver)
Specify a custom TraversableResolver to use for this ValidatorFactory and its exposed default Validator. |
| public void | setValidationMessageSource(MessageSource messageSource)
Specify a custom Spring MessageSource for resolving validation messages, instead of relying on JSR-303's default "ValidationMessages.properties" bundle in the classpath. |
| public void | setValidationProperties(Properties jpaProperties)
Specify bean validation properties to be passed to the validation provider. |
| public void | setValidationPropertyMap(Map<String, String> validationProperties)
Specify bean validation properties to be passed to the validation provider as a Map. |
| public void | setValidationProviderResolver(ValidationProviderResolver validationProviderResolver)
Specify a JSR-303 |
| public <T> T | unwrap(Class<T>
the class of the object to be returned type)Overrides org. Overrides default org. Implements jakarta. |
| public ValidatorContext | usingContext()
Implements jakarta. Validator
compliant this new context.
|
| applicationContext | back to summary |
|---|---|
| private ApplicationContext applicationContext
| |
| configurationInitializer | back to summary |
|---|---|
| private Consumer<Configuration<?>> configurationInitializer
| |
| constraintValidatorFactory | back to summary |
|---|---|
| private ConstraintValidatorFactory constraintValidatorFactory
| |
| mappingLocations | back to summary |
|---|---|
| private Resource[] mappingLocations
| |
| messageInterpolator | back to summary |
|---|---|
| private MessageInterpolator messageInterpolator
| |
| parameterNameDiscoverer | back to summary |
|---|---|
| private ParameterNameDiscoverer parameterNameDiscoverer
| |
| providerClass | back to summary |
|---|---|
private Class<T> providerClass
| |
| traversableResolver | back to summary |
|---|---|
| private TraversableResolver traversableResolver
| |
| validationPropertyMap | back to summary |
|---|---|
| private final Map<String, String> validationPropertyMap | |
| validationProviderResolver | back to summary |
|---|---|
| private ValidationProviderResolver validationProviderResolver
| |
| validatorFactory | back to summary |
|---|---|
| private ValidatorFactory validatorFactory
| |
| LocalValidatorFactoryBean | back to summary |
|---|---|
| public LocalValidatorFactoryBean() | |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() Implements org. Doc from org. Invoked by the containing This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
| |
| close | back to summary |
|---|---|
| public void close() Implements jakarta. Doc from jakarta. Closes the
| |
| closeMappingStreams | back to summary |
|---|---|
| private void closeMappingStreams(List<InputStream> mappingStreams) | |
| configureParameterNameProvider | back to summary |
|---|---|
| private void configureParameterNameProvider(ParameterNameDiscoverer discoverer, Configuration<?> configuration) | |
| destroy | back to summary |
|---|---|
| public void destroy() Implements org. Doc from org. Invoked by the containing
| |
| getClockProvider | back to summary |
|---|---|
| public ClockProvider getClockProvider() Implements jakarta. Doc from jakarta. Returns the
| |
| getConstraintValidatorFactory | back to summary |
|---|---|
| public ConstraintValidatorFactory getConstraintValidatorFactory() Implements jakarta. Doc from jakarta. Returns the
| |
| getMessageInterpolator | back to summary |
|---|---|
| public MessageInterpolator getMessageInterpolator() Implements jakarta. Doc from jakarta. Returns the
| |
| getParameterNameProvider | back to summary |
|---|---|
| public ParameterNameProvider getParameterNameProvider() Implements jakarta. Doc from jakarta. Returns the
| |
| getTraversableResolver | back to summary |
|---|---|
| public TraversableResolver getTraversableResolver() Implements jakarta. Doc from jakarta. Returns the
| |
| getValidationPropertyMap | back to summary |
|---|---|
| public Map Allow Map access to the bean validation properties to be passed to the validation provider, with the option to add or override specific entries. Useful for specifying entries directly, for example via "validationPropertyMap[myKey]". | |
| getValidator | back to summary |
|---|---|
| public Validator getValidator() Implements jakarta. Doc from jakarta. Returns an initialized Validator instances can be pooled and shared by the implementation. | |
| postProcessConfiguration | back to summary |
|---|---|
| protected void postProcessConfiguration(Configuration<?> configuration) Post-process the given Bean Validation configuration, adding to or overriding any of its settings. Invoked right before building the
| |
| setApplicationContext | back to summary |
|---|---|
| public void setApplicationContext(ApplicationContext applicationContext) Implements org. Doc from org. Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object. Invoked after population of normal bean properties but before an init callback such
as
| |
| setConfigurationInitializer | back to summary |
|---|---|
| public void setConfigurationInitializer(Consumer<Configuration<?>> configurationInitializer) Specify a callback for customizing the Bean Validation This enables convenient customizations for application purposes. Infrastructure
extensions may keep overriding the
| |
| setConstraintValidatorFactory | back to summary |
|---|---|
| public void setConstraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory) Specify a custom ConstraintValidatorFactory to use for this ValidatorFactory. Default is a | |
| setMappingLocations | back to summary |
|---|---|
| public void setMappingLocations(Resource... mappingLocations) Specify resource locations to load XML constraint mapping files from, if any. | |
| setMessageInterpolator | back to summary |
|---|---|
| public void setMessageInterpolator(MessageInterpolator messageInterpolator) Specify a custom MessageInterpolator to use for this ValidatorFactory and its exposed default Validator. | |
| setParameterNameDiscoverer | back to summary |
|---|---|
| public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer) Set the ParameterNameDiscoverer to use for resolving method and constructor parameter names if needed for message interpolation. Default is Hibernate Validator's own internal use of standard Java reflection.
This may be overridden with a custom subclass or a Spring-controlled
| |
| setProviderClass | back to summary |
|---|---|
| public void setProviderClass(Class<T> providerClass) Specify the desired provider class, if any. If not specified, JSR-303's default search mechanism will be used.
| |
| setTraversableResolver | back to summary |
|---|---|
| public void setTraversableResolver(TraversableResolver traversableResolver) Specify a custom TraversableResolver to use for this ValidatorFactory and its exposed default Validator. | |
| setValidationMessageSource | back to summary |
|---|---|
| public void setValidationMessageSource(MessageSource messageSource) Specify a custom Spring MessageSource for resolving validation messages, instead of relying on JSR-303's default "ValidationMessages.properties" bundle in the classpath. This may refer to a Spring context's shared "messageSource" bean, or to some special MessageSource setup for validation purposes only. Note This feature requires Hibernate Validator 4.3 or higher on the classpath.
You may nevertheless use a different validation provider but Hibernate Validator's
Specify either this property or In order for Hibernate's default validation messages to be resolved still, your
| |
| setValidationProperties | back to summary |
|---|---|
| public void setValidationProperties(Properties jpaProperties) Specify bean validation properties to be passed to the validation provider. Can be populated with a String "value" (parsed via PropertiesEditor) or a "props" element in XML bean definitions. | |
| setValidationPropertyMap | back to summary |
|---|---|
| public void setValidationPropertyMap(Map<String, String> validationProperties) Specify bean validation properties to be passed to the validation provider as a Map. Can be populated with a "map" or "props" element in XML bean definitions. | |
| setValidationProviderResolver | back to summary |
|---|---|
| public void setValidationProviderResolver(ValidationProviderResolver validationProviderResolver) Specify a JSR-303
| |
| unwrap | back to summary |
|---|---|
| public <T> T unwrap(Class<T> type) Overrides org. Overrides default org. Implements jakarta. Doc from jakarta. Returns an instance of the specified type allowing access to
provider-specific APIs. If the Jakarta Bean Validation provider
implementation does not support the specified class, a
| |
| usingContext | back to summary |
|---|---|
| public ValidatorContext usingContext() Implements jakarta. Doc from jakarta. Defines a new validator context and returns a
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static MessageInterpolator |
| HibernateValidatorDelegate | back to summary |
|---|---|
| private HibernateValidatorDelegate() | |
| buildMessageInterpolator | back to summary |
|---|---|
| public static MessageInterpolator buildMessageInterpolator(MessageSource messageSource) | |