aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/jsonschema.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/util/jsonschema.lua b/util/jsonschema.lua
index 5639236a..1a724815 100644
--- a/util/jsonschema.lua
+++ b/util/jsonschema.lua
@@ -1,6 +1,11 @@
-local schema_t = {xml_t = {}}
+local json = require("util.json")
+local null = json.null;
-local type_e = schema_t.type_e
+local json_type_name = json.json_type_name
+
+local schema_t = {}
+
+local json_schema_object = {xml_t = {}}
local type_validators = {}
@@ -11,6 +16,8 @@ local function simple_validate(schema, data)
return type(data) == "table" and (next(data) == nil or type((next(data, nil))) == "number")
elseif schema == "integer" then
return math.type(data) == schema
+ elseif schema == "null" then
+ return data == null
else
return type(data) == schema
end
@@ -253,4 +260,6 @@ type_validators.array = function(schema, data)
return false
end
-return {validate = validate; schema_t = schema_t}
+json_schema_object.validate = validate;
+
+return json_schema_object