Software /
code /
prosody
Diff
util/jsonschema.lua @ 11448:1d84b54ba0d7
util.jsonschema: Restructure "type" keyword handling
More in line with the other tests
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 09 Mar 2021 14:31:11 +0100 |
parent | 11447:7ad137fe665b |
child | 11460:a8b4e04bc044 |
line wrap: on
line diff
--- a/util/jsonschema.lua Tue Mar 09 14:22:33 2021 +0100 +++ b/util/jsonschema.lua Tue Mar 09 14:31:11 2021 +0100 @@ -110,10 +110,6 @@ end end - if not simple_validate(schema.type, data) then - return false - end - if schema.const ~= nil and schema.const ~= data then return false end @@ -127,12 +123,17 @@ return false end - local validator = type_validators[schema.type] - if not validator then - return true + if schema.type then + if not simple_validate(schema.type, data) then + return false + end + + local validator = type_validators[schema.type] + if validator then + return validator(schema, data) + end end - - return validator(schema, data) + return true end end