JSON Schema validation fails
Following pattern that is fine according to regex tester (regex101.com):
pattern: '^(?!\s)[0-9_.,-\\/ A-Za-z]*(?<!\s)$'
fails:
ERROR - Invalid JSON Schema, cannot continue\n\tSyntax errors:\n\t[ {\n\t \"level\" : \"error\",\n\t \"message\" : \"string \\"^(?!\\s)[0-9_.,\\-\\\\\\/ A-Za-z](?<!\\s)$\\" is not a valid ECMA 262 regular expression\",\n\t \"domain\" : \"syntax\",\n\t \"schema\" : {\n\t \"loadingURI\" : \"#\",\n\t \"pointer\" : \"/properties/name/allOf/0\"\n\t },\n\t \"keyword\" : \"pattern\",\n\t \"value\" : \"^(?!\\s)[0-9_.,\\-\\\\\\/ A-Za-z](?<!\\s)$\"\n\t} ]: []
Comments (3)
-
-
Last year I’ve created a pull request on the java-json-tools dependency that will add support for the latest ECMAScript. But no one has accepted it, yet: https://github.com/java-json-tools/json-schema-core/pull/97
-
- changed status to closed
Awaiting upstream fix
- Log in to comment
The Regex is using lookbehind assertions. That is supported since ECMAScript 2018.
The used JavaScript engine (either Nashorn or Rhino) in the project only supports ECMAScript 5 (2009).