Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2158

Client-side validation of @Size is not working when only min or max is set

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 5.4
    • 5.4
    • tapestry-beanvalidator
    • None

    Description

      Exact version: 5.4-alpha-14

      Server side example:

      @Size(min = 3)
      private String name;
      

      On the client side the following function gets executed:

      doRangeValidate = function(element, value, memo) {
            var max, min;
      
            min = rangeValue(element, "data-range-min", 0);
            max = rangeValue(element, "data-range-max", Number.MAX_VALUE);
            if (_.isString(value)) {
              value = value.length;
            }
            if (!((min <= value && value <= max))) {
              memo.error = (element.attribute("data-range-message")) || "RANGE ERROR";
              return false;
            }
            return true;
          };
      

      In the above example max is evaluated to NaN and therefore the function returns false causing validation error.

      Same applies when you only max is specified in @Size annotation and min is evaluated to NaN.

      Workaround

      Specify both min and max.

      Attachments

        Issue Links

          Activity

            People

              thiagohp Thiago Henrique De Paula Figueiredo
              balapal Balázs Palcsó
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: