You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Lenny Primak (JIRA)" <ji...@apache.org> on 2013/09/09 19:10:51 UTC

[jira] [Commented] (TAP5-2158) Client-side validation of @Size is not working when only min or max is set

    [ https://issues.apache.org/jira/browse/TAP5-2158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13762044#comment-13762044 ] 

Lenny Primak commented on TAP5-2158:
------------------------------------

I would say this is a critical bug, not minor. 
                
> Client-side validation of @Size is not working when only min or max is set
> --------------------------------------------------------------------------
>
>                 Key: TAP5-2158
>                 URL: https://issues.apache.org/jira/browse/TAP5-2158
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-beanvalidator
>    Affects Versions: 5.4
>            Reporter: Balázs Palcsó
>            Priority: Minor
>
> Exact version: 5.4-alpha-14
> Server side example:
> {code}
> @Size(min = 3)
> private String name;
> {code}
> On the client side the following function gets executed:
> {code}
> 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;
>     };
> {code}
> 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.
> h3. Workaround 
> Specify both min and max.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira