开发者

Locale based validation

My project have two main requirements

1) Different set of rules applied to same object at insertion and while updating it.

2) Different validation rules based on locale.

In ADDRESS object STATE field requires different validation rules For USA: STATE cannot be NULL. For everywhere 开发者_StackOverflow社区else it can be NULL.

For first requirement i am already using GROUPS. Is there a way to achieve second requirements.

I am using: Hibernate Validator 4.0.1 GA Hibernate 5.2.6


I would make the country (Locale based or not is up to you) part of the Address and use a custom class-level constraint to do the validation.


This question got answered on the Hibernate Validator forum. Best way to go is a class-level constraint or a Validator instance per Locale. I really wouldn't recommend the latter, but it's a possibility.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜