spring-framework / org.springframework.validation.beanvalidation / OptionalValidatorFactoryBean

OptionalValidatorFactoryBean

open class OptionalValidatorFactoryBean : LocalValidatorFactoryBean

LocalValidatorFactoryBean subclass that simply turns org.springframework.validation.Validator calls into no-ops in case of no Bean Validation provider being available.

This is the actual class used by Spring's MVC configuration namespace, in case of the javax.validation API being present but no explicit Validator having been configured.

Author
Juergen Hoeller

Since
4.0.1

Constructors

<init>

OptionalValidatorFactoryBean()

LocalValidatorFactoryBean subclass that simply turns org.springframework.validation.Validator calls into no-ops in case of no Bean Validation provider being available.

This is the actual class used by Spring's MVC configuration namespace, in case of the javax.validation API being present but no explicit Validator having been configured.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

Inherited Functions

close

open fun close(): Unit

destroy

open fun destroy(): Unit

getConstraintValidatorFactory

open fun getConstraintValidatorFactory(): ConstraintValidatorFactory

getMessageInterpolator

open fun getMessageInterpolator(): MessageInterpolator

getParameterNameProvider

open fun getParameterNameProvider(): ParameterNameProvider

getTraversableResolver

open fun getTraversableResolver(): TraversableResolver

getValidationPropertyMap

open fun getValidationPropertyMap(): MutableMap<String, String>

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

open fun getValidator(): Validator

setApplicationContext

open fun setApplicationContext(applicationContext: ApplicationContext): Unit

setConstraintValidatorFactory

open fun setConstraintValidatorFactory(constraintValidatorFactory: ConstraintValidatorFactory): Unit

Specify a custom ConstraintValidatorFactory to use for this ValidatorFactory.

Default is a SpringConstraintValidatorFactory, delegating to the containing ApplicationContext for creating autowired ConstraintValidator instances.

setMappingLocations

open fun setMappingLocations(vararg mappingLocations: Resource): Unit

Specify resource locations to load XML constraint mapping files from, if any.

setMessageInterpolator

open fun setMessageInterpolator(messageInterpolator: MessageInterpolator): Unit

Specify a custom MessageInterpolator to use for this ValidatorFactory and its exposed default Validator.

setParameterNameDiscoverer

open fun setParameterNameDiscoverer(parameterNameDiscoverer: ParameterNameDiscoverer): Unit

Set the ParameterNameDiscoverer to use for resolving method and constructor parameter names if needed for message interpolation.

Default is a org.springframework.core.DefaultParameterNameDiscoverer.

setProviderClass

open fun setProviderClass(providerClass: Class<Any>): Unit

Specify the desired provider class, if any.

If not specified, JSR-303's default search mechanism will be used.

setTraversableResolver

open fun setTraversableResolver(traversableResolver: TraversableResolver): Unit

Specify a custom TraversableResolver to use for this ValidatorFactory and its exposed default Validator.

setValidationMessageSource

open fun setValidationMessageSource(messageSource: MessageSource): Unit

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 ResourceBundleMessageInterpolator class must be accessible during configuration.

Specify either this property or "messageInterpolator", not both. If you would like to build a custom MessageInterpolator, consider deriving from Hibernate Validator's ResourceBundleMessageInterpolator and passing in a Spring-based ResourceBundleLocator when constructing your interpolator.

setValidationProperties

open fun setValidationProperties(jpaProperties: Properties): Unit

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

open fun setValidationPropertyMap(validationProperties: MutableMap<String, String>): Unit

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

open fun setValidationProviderResolver(validationProviderResolver: ValidationProviderResolver): Unit

Specify a JSR-303 ValidationProviderResolver for bootstrapping the provider of choice, as an alternative to META-INF driven resolution.

unwrap

open fun <T : Any> unwrap(type: Class<T>): T

usingContext

open fun usingContext(): ValidatorContext