aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--teal-src/util/jsonschema.tl19
-rw-r--r--util/jsonschema.lua19
2 files changed, 20 insertions, 18 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
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