Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue on Form Validator with pattern ? #869

Closed
elaugier opened this issue Sep 20, 2016 · 6 comments
Closed

Issue on Form Validator with pattern ? #869

elaugier opened this issue Sep 20, 2016 · 6 comments

Comments

@elaugier
Copy link

elaugier commented Sep 20, 2016

Hello,

It's seems to be an issue with some Regex. I explain.

I have an input like this :

        <div class="input-control text full-size" data-role="input">
            <input id="password"
                   name="password"
                   placeholder="{{TC.translation.STR0020[TC.language]}}"
                   type="password"
                   data-validate-func="pattern"
                   data-validate-arg="^(?=.*[a-zA-Z]{1,})(?=.*[\d]{0,})[a-zA-Z]{8,20}$"
                   data-validate-hint="Password don't match with complexity rules"
                   ng-pattern="/^(?=.*[a-zA-Z]{1,})(?=.*[\d]{0,})[a-zA-Z]{8,20}$/"
                   ng-model="ACC.accountActivationFormF.password">

            <button class="button helper-button clear"><span class="mif-cross"></span></button>
        </div>

And I got an error in metro.js at line 9203 because the function try to instantiate a Regex object with value (?=.*[a-zA-Z]{1, . I searched why and i think the error is at line 9295

arg = input.data('validateArg') != undefined ? String(input.data('validateArg')).split(",") : [];

My regexp contains a comma ... So when you split by comma, my regexp stops working.

I try to remove the split : it's works... But i think that it's not the best solution.

Any idea?

Thanks for your help,

@budus
Copy link

budus commented Nov 13, 2016

I have the same problem with a simple regexp:

data-validate-arg="^[0-9]{3,}$"

With a previous version (3.0.13) of Metro this regexp works perfectly.

For the moment I use the same solution but this seems a bug.

@budus
Copy link

budus commented Nov 13, 2016

Remove only the split isn't correct: regexp always return true !

I have modified the code like this:
`
if (func == 'pattern') {
arg = input.data('validateArg') != undefined ? String(input.data('validateArg')) : [];
//console.log(input.data('validateArg'));
}

        $.each(func, function(i, func_name){
            if (!this_result) return;
            var _args = arg[i] != undefined ? arg[i] : false;
            if (func == 'pattern') {
                this_result = that.funcs[func](input.val(), arg);
            } else {
                this_result = that.funcs[func_name.trim()](input.val(), _args);
            }
        });

`

@weagle08
Copy link

Same issue, @budus could you submit a pull request with your fix?

@olton
Copy link
Owner

olton commented Nov 23, 2016

I did added this problem to TODO for next version

olton added a commit that referenced this issue Nov 24, 2016
@olton
Copy link
Owner

olton commented Nov 24, 2016

fixed in develop branch

olton added a commit that referenced this issue Nov 24, 2016
@olton
Copy link
Owner

olton commented Sep 14, 2017

Metro 4, Validator
https://metroui.org.ua/v4/validator.html

@olton olton closed this as completed Sep 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants