When using nested patternProperties regex not works #626
Replies: 2 comments 2 replies
-
| 
 JSON Schema, per the specification, will just ignore that property. | 
Beta Was this translation helpful? Give feedback.
-
| I can't speak for proprietary VSCode functionality, but I did notice a bug in your schema that could be the cause of the problem   "oneOf": [
    {
      "$ref": "#/definitions/kebabCase"
    },
    {
      "type": "object",
      "patternProperties": {
        "^[a-z0-9_]+$": {
          "$ref": "#/definitions/kebabCase",
          "errorMessage": "Invalid property name. Use snake_case."
        }
      }
    }
  ],
  "additionalProperties": falseThe scope of  There's a keyword called  | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When I use nested patternProperties, in the key the regex works but the error message is the default one and not the one I defined in the scheme and in the subkey the error follows what is defined but the regex does not work, it reports an error even though it is correct.
I'm using VSCode.
//color-semantic.schema.json
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "$schema": { "type": "string" } }, "patternProperties": { "^[a-z0-9_]+$": { "$ref": "#/definitions/colorReference", "errorMessage": "Invalid property name. Use snake_case." } }, "additionalProperties": false, "definitions": { "kebabCase": { "type": "string", "pattern": "^[a-z0-9-]+$", "errorMessage": "Invalid property name. Use kebab-case." }, "colorReference": { "oneOf": [ { "$ref": "#/definitions/kebabCase" }, { "type": "object", "patternProperties": { "^[a-z0-9_]+$": { "$ref": "#/definitions/kebabCase", "errorMessage": "Invalid property name. Use snake_case." } } } ], "additionalProperties": false } } }//color-semantic.tokens.json
{ "$schema": "../src/types/color-semantic.schema.json", "surface-": { // Error: Property surface- is not allowed. "minus_1": "neutral-transparent-30", // Error: Invalid property name. Use snake_case. "0": "neutral-opaque-0", "1": "neutral-opaque-30", "2": "neutral-opaque-60" } }Beta Was this translation helpful? Give feedback.
All reactions