I want to validate YAML files in Python with my own scheme. A valid YAML shall look like this:
input: - name1 split_to: windows: - split1 other: - split2
While [windows, other] are dynamic, any name shall allowed there (i.e. “solaris”, “mac”, “templeOS”)
I’m using validate from jsonschema like described here: Validating a yaml document in python
Any other module where this works would be also okay.
Advertisement
Answer
You’re searching for additionalProperties:
type: object properties: input: type: array items: type: string split_to: type: object additionalProperties: type: array items: type: string additionalProperties: false
Setting it to false
disallows unknown properties in the root mapping. Since JSON Schema is for JSON, keys will always be strings and you can set only the value type for additional properties.