diff options
author | Kim Alvefur <zash@zash.se> | 2021-03-09 02:26:05 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-03-09 02:26:05 +0100 |
commit | 6a7346ac8e06ff00ba016141ccda99b4af83347e (patch) | |
tree | 0986d20a1b5293e1b8b51da08589bcfb00bf95bb /util | |
parent | 07889f274dfb3dbb17988688701602cc43291941 (diff) | |
download | prosody-6a7346ac8e06ff00ba016141ccda99b4af83347e.tar.gz prosody-6a7346ac8e06ff00ba016141ccda99b4af83347e.zip |
util.jsonschema: Correct "items" keyword
Upon re-reading the JSON Schema spec, I found that 'items' wasn't a
union of an array of schemas or a single schema, not sure where I got
that from.
Diffstat (limited to 'util')
-rw-r--r-- | util/jsonschema.lua | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/util/jsonschema.lua b/util/jsonschema.lua index cc182773..23a47bd7 100644 --- a/util/jsonschema.lua +++ b/util/jsonschema.lua @@ -194,20 +194,12 @@ type_validators.table = function(schema, data) return true end - local item_schemas = schema.items - if item_schemas and item_schemas[1] == nil then - local item_schema = item_schemas - for i, v in pairs(data) do - if type(i) == "number" then - if not validate(item_schema, v) then - return false - end + if schema.items then + for i = 1, #data do + if not validate(schema.items, data[i]) then + return false end end - elseif item_schemas and item_schemas[1] ~= nil then - for i, s in ipairs(item_schemas) do - validate(s, data[i]) - end end return true |