Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    IntegerRangeValidator not detecting value outside range

    Isomorphic,

    This issue can be reproduced with the following showcase example:

    http://www.smartclient.com/smartgwt/...ation_builtins

    If you enter a number that is not a safe integer such as "9007199254740993" you will not receive a validation error.

    Is this the expected behavior?

    Thanks.

    #2
    It is a designed-in and documented behavior intended to preserve values that are outside of the max integer range of JavaScript, by leaving them as Strings. See dataSourceField.stringInBrowser for details, and note that stringInBrowser="false" will avoid this problem and cause validation errors to show again.

    However we are probably going to alter the behavior for this particular case. If you have a lengthRange value with a max, it seems pretty clear that you are not trying to preserve values outside of JavaScript's integer range..

    Comment


      #3
      Thanks, I'll take a look at this setting.

      Comment


        #4
        Isomorphic,

        I've tried setting stringInBrowser="false"; however, it's still possible to enter a large value and not get a validation error. For example, if you enter "123456789012345678901234567890" and click the Validate button, the value changes to "1.2345678901234568e+29" and there is no validation error.

        Since we're not using the localeInt field type, do you recommend just setting the length of the IntegerItem to the maximum number of digits required for the min/max values?

        Here is the Entry Point:
        Code:
            @Override
            public void onModuleLoad() {
                DataSource dataSource = new DataSource();
        
                IntegerRangeValidator integerRangeValidator = new IntegerRangeValidator();
                integerRangeValidator.setMin(Integer.MIN_VALUE);
                integerRangeValidator.setMax(Integer.MAX_VALUE);
        
                DataSourceIntegerField dsIntegerField = new DataSourceIntegerField("intField");
                dsIntegerField.setTitle("Integer");
                dsIntegerField.setAttribute("stringInBrowser", Boolean.FALSE);
                dsIntegerField.setValidators(integerRangeValidator);
        
                dataSource.setFields(dsIntegerField);
        
                final DynamicForm form = new DynamicForm();
                form.setWidth(300);
                form.setDataSource(dataSource);
        
                IButton validateButton = new IButton();
                validateButton.setTitle("Validate");
                validateButton.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        form.validate();
                    }
                });
        
                HLayout hLayout = new HLayout();
                hLayout.setMembersMargin(10);
                hLayout.addMember(form);
                hLayout.addMember(validateButton);
        
                hLayout.draw();
            }
        Thanks.
        Last edited by stonebranch3; 9 Mar 2016, 09:56.

        Comment

        Working...
        X