aspnet/jquery-validation-unobtrusive

Add support for Unicode property escapes in regex validation

KoshelevS opened this issue · 1 comments

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">

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.