aboutsummaryrefslogtreecommitdiffstats
path: root/util/jsonschema.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-03-18 23:57:03 +0100
committerKim Alvefur <zash@zash.se>2021-03-18 23:57:03 +0100
commitc1706af956ae403b229f7f37a2ff575ada0074e6 (patch)
tree8a6f328deddcec490d84601091dbad7b9ecf1f9b /util/jsonschema.lua
parentd18097fb6700ede8bdb47388e51e0850d0d828f6 (diff)
downloadprosody-c1706af956ae403b229f7f37a2ff575ada0074e6.tar.gz
prosody-c1706af956ae403b229f7f37a2ff575ada0074e6.zip
util.jsonschema: Rename types for improved readability
Diffstat (limited to 'util/jsonschema.lua')
-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