protected void initRules ( ) { this . validationRules = new Rules ( getClass ( ) ) { protected void initRules ( ) { add ( PROPERTY_USERNAME , all ( new Constraint [ ] { required ( ) , minLength ( getUsernameMinLength ( ) ) } ) ) ; add ( PROPERTY_PASSWORD , all ( new Constraint [ ] { required ( ) , minLength ( getPasswordMinLength ( ) ) } ) ) ; } protected int getUsernameMinLength ( ) { return 2 ; } protected int getPasswordMinLength ( ) { return 2 ; } } ; }
Initialize the field constraints for our properties . Minimal constraints are enforced here . If you need more control you should override this in a subtype .