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

Default values not taken into account for conditional schema #228

Open
didier-brizet opened this issue Sep 27, 2022 · 2 comments · May be fixed by #230
Open

Default values not taken into account for conditional schema #228

didier-brizet opened this issue Sep 27, 2022 · 2 comments · May be fixed by #230
Labels

Comments

@didier-brizet
Copy link
Contributor

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

@didier-brizet
Copy link
Contributor Author

I propose the following patch.

issue_226.txt

@pboettch
Copy link
Owner

Could you please create a pull-request with your change? It will be much easier to review. Thanks.

@didier-brizet didier-brizet linked a pull request Sep 28, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants