validation - Can hibernate validator be used to validate a field depending on a field value from another class -


i have scenario need validate fields of class depending on value of field class.

for ex: street, city, postal code of address class should not null if employee has registered group retirement plan.

can scenario handled using custom validator of hibernate validator? candidate hibernate validator ? if so, provide me examples.

i have gone through cross field validation examples like: cross field validation hibernate validator (jsr 303)

if have boolean indicator indicate whether user registered group retirement plan in address domain class, know can come custom validator verify fields. but, want avoid adding indicator address class. well, address not field in employee class nested validation.

the frameworks using spring mvc , mybatis data access. validation happening @ spring rest api call @valid annotation.

i guess custom class level constraint might work, depends on actual domain classes. not clear how example employee, group retirement plan , these other entities connected.

whether hibernate validator fit whether have other validations or other frameworks involved. example, if want validation take place @ jpa live cycle events, bean validation fit, since integrates per specification jpa. if have 1 validation, writing custom code might need.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo