Client side Pattern validator should allow unicode regex patterns

It is not possible to setup a pattern validation for national characters.
@Pattern(regexp = “[1]+$”) does not work
Also attempts to use \uXXXX-\uXXXX do not work.
Regex //u modifier would be needed.


  1. \p{L}\s- ↩︎

Maybe flags can be added manually on client side by accessing the binder.validator.regex.flags

Should’nt it be

@Pattern(regexp = "[\\p{L}\\s-]+")

@Pattern(regexp = “[1]+$”)
private String firstName;


  1. \p{L}\s- ↩︎

Hm it seems that when I paste it , discord removes backslashes

I am going to test adding flags

you have to use three back ticks to paste code

But the problem are indeed the backslashes

the generate code looks like this

return this[_getPropertyModel]('lastName', StringModel, [true, new NotBlank(), new Pattern({regexp:"^[\\p{L}\\s-]+$"})]);

But there shouldn’t be double backslashes

You should open an issue

Let me test that

I changed model to this

get firstName(): StringModel {
return this[_getPropertyModel](‘firstName’, StringModel, [true, new NotBlank(),
new Pattern({regexp:“[1]+$”}), new Size({max:15})]);
}


  1. \p{L}\s- ↩︎

still does not accept any input

I looks like the regex cannot be parsed on the clientside

/u flag is needed for that i guess

let validators = this.binder.for(this.binder.model.firstName).validators;
validators.forEach(v => {
const p: Pattern = v;
p.regexp = new RegExp(p.regexp, ‘u’)
console.log(v);
});

It uses GitHub - validatorjs/validator.js: String validation