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

NON required property having required properties #102

Closed
koxon opened this issue May 5, 2014 · 3 comments
Closed

NON required property having required properties #102

koxon opened this issue May 5, 2014 · 3 comments

Comments

@koxon
Copy link

koxon commented May 5, 2014

I have a NON required property object "client".
"client" however has required properties if present.

"client" properties should be checked ONLY if "client" is present.
The validator does the check no matter what. So the validation fails when "client" property is not present.
I tested the below data/schema with the Java validator and it works (see: http://json-schema-validator.herokuapp.com/), however with this PHP validator it fails.

Data

{
    "command": "StartJob",
    "data": {
        "input_type": "VIDEO",
        "outputs": 
        [
            {
                "output_type": "VIDEO"
            }
        ]
    }
}

Schema:

{
    "id": "http://test.com/input-schema/ValidateInputAsset#",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Schema for activity task",
    "type": "object",
    "properties": {
        "client": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "externalId": {
                    "type": "string"
                },
                "role": {
                    "type": "string"
                }
            },
            "required": ["name", "role"],
            "additionalProperties": true
        },
        "command": {
            "type": "string"
        },
        "data" : {
            "type": "object"
       }
    },
    "required": ["command", "data"],
    "additionalProperties": true
}
alexmmm added a commit to alexmmm/json-schema that referenced this issue May 5, 2014
alexmmm added a commit to alexmmm/json-schema that referenced this issue May 5, 2014
alexmmm added a commit to alexmmm/json-schema that referenced this issue May 5, 2014
@koxon
Copy link
Author

koxon commented May 27, 2014

Thanks for the fix!

@adamthehutt
Copy link

Is this fix going to be merged? I'm having this problem as well and it's a blocker for me. Thanks.

@justinrainbow
Copy link
Collaborator

The fix by @alexmmm has now been merged

hakre pushed a commit to hakre/json-schema that referenced this issue Mar 26, 2015
siwinski pushed a commit to siwinski/json-schema that referenced this issue Apr 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants