Invalid regex (iso8601Pattern) when building with ajv ^8.8.2
See original GitHub issueDescribe the bug
When I run sls deploy
I a regex error:
SyntaxError: Invalid regular expression: /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/: Invalid escape
at new RegExp (<anonymous>)
at defaultRegExp (C:\dev\test-slic-watch\nexus\node_modules\ajv\lib\core.ts:66:53)
I think it’s this regex: https://github.com/fourTheorem/slic-watch/blob/main/serverless-plugin/config-schema.js#L6
To Reproduce
sls deploy
Expected behavior
Environment:
- OS: Windows
- Node.js Version: 14.18.0
- NPM version: 6.14.15
- Serverless Framework Version: Framework Core: 2.69.1 (local) Plugin: 5.5.1 SDK: 4.3.0 Components: 3.18.1
Additional context
We are using serverless-esbuild
plugin which uses esbuild to build the code.
https://github.com/floydspace/serverless-esbuild
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Regex pattern not validated correctly · Issue #1304 - GitHub
Problem: A pattern [0-9]{5} with the input 123456 (one char too long) does not lead to a validation error. What version of Ajv...
Read more >How do I validate a string using a regular expression with Ajv?
The documentation about format state that : regex: tests whether a string is a valid regular expression by passing it to RegExp constructor....
Read more >Ajv JSON schema validator - npm
Ajv JSON schema validator. The fastest JSON validator for Node.js and browser. Supports JSON Schema draft-04/06/07/2019-09/2020-12 (draft-04 ...
Read more >API Reference | Ajv JSON schema validator
The schema passed to this method will be validated against meta-schema unless validateSchema option is false. If schema is invalid, an error will...
Read more >ajv-formats - Ajv JSON schema validator
ipv6: IP address v6. regex: tests whether a string is a valid regular expression by passing it to RegExp constructor. uuid: Universally Unique...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Narrowed it down to this unicode flag that Ajv adds when creating the regex:
Error:
Hey @eoinsha I’ve managed to reproduce the issue 😃 Our project is using
"ajv": "^8.8.2"
. If you upgrade the test project to that version and runnpm run test
(which calls sls package) it will throw that regex error.