Skip to content

NON required property having required properties #102

@koxon

Description

@koxon

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions