aspnet / jquery-validation-unobtrusive

Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.
MIT License
257 stars 113 forks source link

Add support for Unicode property escapes in regex validation #142

Closed KoshelevS closed 2 years ago

KoshelevS commented 3 years ago

It looks like the library does not support Unicode property escapes like \p{L} in regex validation. Can we add this support.

I think we can change

match = new RegExp(params).exec(value);

here https://github.com/aspnet/jquery-validation-unobtrusive/blob/main/src/jquery.validate.unobtrusive.js#L346 to

match = new RegExp(params[0], params[1]).exec(value);

and

    adapters.addSingleVal("regex", "pattern");

here https://github.com/aspnet/jquery-validation-unobtrusive/blob/main/src/jquery.validate.unobtrusive.js#L369 to

    adapters.add("regex", ["pattern", "flags"], function (options) {
        setValidationValues(options, "regex", [options.params.pattern, options.params.flags || ""]);
    });

to add this support.

Usage: <input type="text" data-val-regex-pattern="^[\p{L}]+$" data-val-regex-flags="u" value="asdf">

mkArtakMSFT commented 2 years ago

Hi. Thanks for contacting us. We're closing this issue as there was not much community interest in this ask for quite a while now. You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.