diff options
Diffstat (limited to 'util/jsonschema.lua')
-rw-r--r-- | util/jsonschema.lua | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/util/jsonschema.lua b/util/jsonschema.lua index eafa8b7c..3160229f 100644 --- a/util/jsonschema.lua +++ b/util/jsonschema.lua @@ -3,10 +3,10 @@ local m_type = function(n) return type(n) == "number" and n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float"; end; -local json = require("util.json") +local json = require("prosody.util.json") local null = json.null; -local pointer = require("util.jsonpointer") +local pointer = require("prosody.util.jsonpointer") local json_type_name = json.json_type_name @@ -206,6 +206,18 @@ function complex_validate(schema, data, root) 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 @@ -232,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 = {} |