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

'v' pattern flag support, log descriptive errors for invalid (failing to compile) regexp's #2458

Closed
ekzobrain opened this issue Jun 26, 2024 · 2 comments

Comments

@ekzobrain
Copy link

What version of Ajv you are you using?
latest

What problem do you want to solve?
Missing support for new 'v' regexp flag (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class#v-mode_character_class).
Now regexp, that fail to compile, break validator totally. An exception is not descriptive, it's hard to find the location of a failing pattern keyword.

What do you think is the correct solution to problem?
Add optional support for new 'v' regexp flag. Catch regexp initialization exceptions and log descriptive errors to console including invalid regexp itself. For example: "pattern 'xxx' at failed to compile with 'u' flag: . Check regexp validity or try changing compilation flag".

Will you be able to implement it?
Yes, but need to discuss new option for enabling 'v' flag.

@jasoniangreen
Copy link
Collaborator

Hi @ekzobrain thanks for raising this. Can you prepare an example in runkit to help fast track investigation?

@jasoniangreen
Copy link
Collaborator

This is supported by the regexp keyword in the ajv-keywords project.
https://ajv.js.org/packages/ajv-keywords.html#regexp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants