Skip to content

Default values not taken into account for conditional schema #228

Open
@didier-brizet

Description

@didier-brizet

Default values of sub-schema are not taken into account when a conditional schema is validated.

For instance , an empty JSON document must be validated against the follow JSON schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
   "default": {},
    "properties": {
        "condition": {
          "type": "boolean",
          "default": false
        },
        "data": {
          "type": "string"
        }
    },
    "if": {
        "properties": { "condition": { "const": true } }
    },
    "then": {
        "required": ["data"]
    }
}

The property condition is not defined in document to validate but its default value should be used to test the if condition.

The current implementation of json-schema-validator throws an exception of type std::invalid_argument: At of {} - required property 'data' not found in object

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions