What is best approach to validate a Java bean against custom validation rules? -


public class user {     private string name;     private integer age;     public string getname() {         return this.name;     }     public void setname(string name) {         this.name = name;     }     public integer getage() {         return this.age;     }     public void setage(integer age) {         this.age = age;     } } 

here want validate these fields using custom rule set defined in database each field.

e.g. validate length of name field - length validation can different different companies.

scenario : company x, max length of name field can 20. company y, max length of name field can 30. how apply validation criteria runtime?

see link, bean validation

you can find below link full example.

http://howtodoinjava.com/spring/spring-mvc/spring-bean-validation-example-with-jsr-303-annotations/


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -