Mercurial > prosody-hg
diff util/jsonschema.lua @ 12989:dee080c2441e
util.jsonschema: Implement 'dependentSchemas'
If this object key exists then this schema must validate against the
current object. Seems useful.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 26 Mar 2023 15:20:07 +0200 |
| parents | 8592770be63a |
| children | 87f646e353cf |
line wrap: on
line diff
--- a/util/jsonschema.lua Sun Mar 26 15:19:14 2023 +0200 +++ b/util/jsonschema.lua Sun Mar 26 15:20:07 2023 +0200 @@ -244,6 +244,14 @@ end end + if schema.dependentSchemas then + for k, sub in pairs(schema.dependentSchemas) do + if data[k] ~= nil and not validate(sub, data, root) then + return false + end + end + end + if schema.uniqueItems then local values = {}
