[[mvc-config-validation]]
= Validation

[.small]#xref:web/webflux/config.adoc#webflux-config-validation[See equivalent in the Reactive stack]#

By default, if xref:core/validation/beanvalidation.adoc#validation-beanvalidation-overview[Bean Validation] is present
on the classpath (for example, Hibernate Validator), the `LocalValidatorFactoryBean` is
registered as a global xref:core/validation/validator.adoc[Validator] for use with `@Valid` and
`@Validated` on controller method arguments.

You can customize the global `Validator` instance, as the
following example shows:

include-code::./WebConfiguration[tag=snippet,indent=0]

Note that you can also register `Validator` implementations locally, as the following
example shows:

include-code::./MyController[tag=snippet,indent=0]

TIP: If you need to have a `LocalValidatorFactoryBean` injected somewhere, create a bean and
mark it with `@Primary` in order to avoid conflict with the one declared in the MVC configuration.



