Software /
code /
prosody
Diff
util/jsonschema.lua @ 11460:a8b4e04bc044
util.jsonschema: Rename types for improved readability
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 18 Mar 2021 23:57:03 +0100 |
parent | 11448:1d84b54ba0d7 |
child | 12132:4ff0d33dfb2b |
line wrap: on
line diff
--- a/util/jsonschema.lua Thu Mar 18 23:16:41 2021 +0100 +++ b/util/jsonschema.lua Thu Mar 18 23:57:03 2021 +0100 @@ -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 @@ 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 @@ return false end -return {validate = validate; schema_t = schema_t} +json_schema_object.validate = validate; + +return json_schema_object