Announcement Announcement Module
Collapse
No announcement yet.
How to activate Hibernate validation only when the field is not null nor blank? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to activate Hibernate validation only when the field is not null nor blank?

    I have the following validation for a string field. Hibernate validation is always invoked when I submit the web page. However, if the field in the web page is blank, the validation should be skipped. Any suggestion is greatly appreciated.

    Code:
    @Size(min=2, max=2, message="The month must be two digits")
    @Range(min=1, max=12, message="{The month must be in the range of 01-12}")
    private String month;

  • #2
    Hi, have you tried to create your own validator?

    Comment


    • #3
      No. This is a very basic requirement for a validation framework. It is hard to believe that I have to write my own validator for this issue.

      Comment

      Working...
      X