1

I have to implement an logic for age validation with based on gender, For Example if gender is 'Male' then i need to validate age as '25' or above '25' and if gender is 'Female' then i need to validate age as '18' or above '18'.

I can able to do in if-else condition based but i want achieve through bean validation.

     @NotBlank
     private String gender;
     @NotBlank
     private String age;

     //getter and setter

Please help me resolve my issue.

pandiaraj
  • 580
  • 1
  • 6
  • 18
  • This is called cross fields validation, and it is topic of this question http://stackoverflow.com/questions/1972933/cross-field-validation-with-hibernate-validator-jsr-303 - the `@ScriptAssert` answer should work for you (http://stackoverflow.com/a/4123269/280244) – Ralph Sep 07 '16 at 16:14
  • Thanks Ralph, i referred that post it's more helpful to resolve the my scenario and solved. Once again thanks – pandiaraj Sep 09 '16 at 11:11

0 Answers0