Mercurial > prosody-hg
diff util/jsonschema.lua @ 12988:8592770be63a
util.jsonschema: Implement 'dependentRequired'
If this field exists, then these fields must also exist.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 26 Mar 2023 15:19:14 +0200 |
| parents | d10957394a3c |
| children | dee080c2441e |
line wrap: on
line diff
--- a/util/jsonschema.lua Sun Mar 26 13:13:31 2023 +0200 +++ b/util/jsonschema.lua Sun Mar 26 15:19:14 2023 +0200 @@ -206,6 +206,18 @@ end end + if schema.dependentRequired then + for k, reqs in pairs(schema.dependentRequired) do + if data[k] ~= nil then + for _, req in ipairs(reqs) do + if data[req] == nil then + return false + end + end + end + end + end + if schema.propertyNames ~= nil then for k in pairs(data) do if not validate(schema.propertyNames, k, root) then
