Skip to content

"additionalPatternProperties": validate properties by pattern, excluding ones listed in "properties" #76

Closed
@dmikov

Description

@dmikov

I encountered a very cumbersome issue, which might be related to implementation of validators, but the ones I tried all do it.

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "version": {
            "type": "string"
        },
        "image64":{
            "type": "string"
        }
    },
    "required": [
        "version"
    ],
    "patternProperties": {
        "^[A-Za-z0-9_]+$": {
            "title": "Task Name"
            "type": "object",
            "properties": {
                "action":{
                    "type": "string"
                },
                "schedule": {
                    "type": "object",
                    "properties": {
                        "timedelta": {
                            "type": "object",
                            "properties": {
                                "minutes": {
                                    "type": "integer"
                                }
                            },
                            "required": [
                                "minutes"
                            ]
                        }
                    },
                    "required": [
                        "timedelta"
                    ]
                }
            }
        }
    }
}

The version and image64 property fail validation since they are catched by regex on pattern and therefore must be object and not string. Yes I can write a regex excluding them, but what happen if I need to add one more static property? Edit it again. I think requiring evaluation of static properties first should be mandatory to avoid this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions