0 Replies Latest reply on Oct 19, 2011 4:13 PM by uririch

    JSF 2 validation

    uririch

      Hi,

      I am using validation annotations in my managed bean to validate text input. Here are the annotations:

       

       

      @Size(min=0, max=20, message = "Value cannot be more than 20 characters")
      @Pattern(regexp = "[^|]", message = "Invalid entry. See field description.")  
      private String txt;
      

       

      The size annotation enforces a length but does not force input. The second one throws an error when a pipe character is found in the string. But when a user leaves the field blank and clicks submit,the pattern error is thrown. Why is this happening when the field is blank?

       

      Thanks.