Software /
code /
prosody
Changeset
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 |
parents | 11447:7ad137fe665b |
children | 11449:dabd1fae0540 |
files | teal-src/util/jsonschema.tl util/jsonschema.lua |
diffstat | 2 files changed, 20 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/teal-src/util/jsonschema.tl Tue Mar 09 14:22:33 2021 +0100 +++ b/teal-src/util/jsonschema.tl Tue Mar 09 14:31:11 2021 +0100 @@ -192,10 +192,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 @@ -209,12 +205,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
--- 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