Q:

How to create a specific validator for a field's model

I want to use a specific validation for a field in my class. It should assure that the username field follow some specific rules.
Can someone point me some docs that show me how to create a validator specifically for a field in a class?
I'm using Spring framework.

A:

Whats wrong with the spring documentation.
The page for that is usually http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html
There are different ways to do that. I personally prefer the javax.validation spring integration instead of the system by spring directly. The creation of a custom validator for an object can be seen in the hibernate-validator (implementation of javax.validation) https://docs.jboss.org/hibernate/validator/4.0.1/reference/en/html/validator-customconstraints.html

