From 6db9456d8881cf0ea4d926384c93d25bc0c94978 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 9 Mar 2021 14:31:11 +0100 Subject: util.jsonschema: Restructure "type" keyword handling More in line with the other tests --- util/jsonschema.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'util') diff --git a/util/jsonschema.lua b/util/jsonschema.lua index ed8c0ccc..5639236a 100644 --- a/util/jsonschema.lua +++ b/util/jsonschema.lua @@ -110,10 +110,6 @@ local function validate(schema, data) 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 @@ local function validate(schema, data) return false end - local validator = type_validators[schema.type] - if not validator then - return true - end + if schema.type then + if not simple_validate(schema.type, data) then + return false + end - return validator(schema, data) + local validator = type_validators[schema.type] + if validator then + return validator(schema, data) + end + end + return true end end -- cgit v1.2.3