Plicatibu
Plicatibu

Reputation: 1722

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.

Upvotes: 0

Views: 25

Answers (1)

mh-dev
mh-dev

Reputation: 5523

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

Upvotes: 1

Related Questions