diff options
author | Kim Alvefur <zash@zash.se> | 2023-03-26 15:20:07 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2023-03-26 15:20:07 +0200 |
commit | 8c9ffa25eb18f8ccdd3d3aa515a01efaf9814680 (patch) | |
tree | ced85b064be32794f596c08c20f2b6f43289d0d3 /util | |
parent | 4bc62438dbabb8fbe7ff3c4eca69c30cc04dd8bd (diff) | |
download | prosody-8c9ffa25eb18f8ccdd3d3aa515a01efaf9814680.tar.gz prosody-8c9ffa25eb18f8ccdd3d3aa515a01efaf9814680.zip |
util.jsonschema: Implement 'dependentSchemas'
If this object key exists then this schema must validate against the
current object. Seems useful.
Diffstat (limited to 'util')
-rw-r--r-- | util/jsonschema.lua | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/util/jsonschema.lua b/util/jsonschema.lua index 1c4dcfbd..3160229f 100644 --- a/util/jsonschema.lua +++ b/util/jsonschema.lua @@ -244,6 +244,14 @@ function complex_validate(schema, data, root) 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 = {} |