aboutsummaryrefslogtreecommitdiffstats
path: root/teal-src
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-03-09 14:31:11 +0100
committerKim Alvefur <zash@zash.se>2021-03-09 14:31:11 +0100
commit6db9456d8881cf0ea4d926384c93d25bc0c94978 (patch)
tree0884d966835b148f77717ac3c733749cfe0d8acf /teal-src
parent44edd47ca85307e1e4886aea59197c2ccec6f47c (diff)
downloadprosody-6db9456d8881cf0ea4d926384c93d25bc0c94978.tar.gz
prosody-6db9456d8881cf0ea4d926384c93d25bc0c94978.zip
util.jsonschema: Restructure "type" keyword handling
More in line with the other tests
Diffstat (limited to 'teal-src')
-rw-r--r--teal-src/util/jsonschema.tl19
1 files changed, 10 insertions, 9 deletions
diff --git a/teal-src/util/jsonschema.tl b/teal-src/util/jsonschema.tl
index 3df17477..87269f01 100644
--- a/teal-src/util/jsonschema.tl
+++ b/teal-src/util/jsonschema.tl
@@ -192,10 +192,6 @@ local function validate(schema : schema_t | type_e | boolean, data : any) : bool
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 @@ local function validate(schema : schema_t | type_e | boolean, data : any) : bool
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