2 Replies Latest reply on Oct 13, 2008 6:06 AM by stenlylee

    rich:beanValidator issue

    stenlylee

       

      <h:inputText value="#{personHome.instance.addr}">
       <rich:beanValidator/>
      </h:inputText>
      


      @Column(length = 50) @Length(min=3, max = 50)
      private String addr;
      


      version:
      richfaces 3.2.2GA
      seam 2.1.0CR1

      problem:
      the value is not required
      but if I keep the inputText empty
      then click submit button
      it always check the value and ask for 3-50 letters

      is this a bug?

      thanks for any reply

        • 1. Re: rich:beanValidator issue
          ilya_shaikovsky

          submitted value in this case is "" but not null.. So length validator in isValid

           public boolean isValid(Object value) {
           if ( value == null ) return true;
           if ( !( value instanceof String ) ) return false;
           String string = (String) value;
           int length = string.length();
           return length >= min && length <= max;
           }
          
          

          just validate its length and so throws the message.

          • 2. Re: rich:beanValidator issue
            stenlylee

            so... it can be consider as a bug?
            because if the value is not requried and it has the length rules, I can't use the beanValidator here