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

Regex pattern escape is not shown in error after validation #246

Open
VityaSchel opened this issue Jun 20, 2021 · 2 comments
Open

Regex pattern escape is not shown in error after validation #246

VityaSchel opened this issue Jun 20, 2021 · 2 comments

Comments

@VityaSchel
Copy link

VityaSchel commented Jun 20, 2021

Steps to reproduce:

  1. set rule { type: 'string', pattern: 'https:\/\/example\.com' }
  2. validate incorrect string with this rule to get error
  3. in error.expected will be:
{
  expected: "https://example.com"
}

instead of

{
  expected: "https:\/\/example\.com"
}
@VityaSchel
Copy link
Author

Also works (doesn't work?), it reproduces if set new RegExp('https:\/\/example\.com') to pattern, escape slashes are not shown. If you set pattern: /https:\/\/example\.com/ then it will fail too.

@VityaSchel
Copy link
Author

My suggestion is to use regexp object inside expected field in error or fix this issue by replacing '\' to '\\' in regex.source

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

1 participant