Software /
code /
prosody
Diff
util/jsonschema.lua @ 12500:88e1b94105ae 0.12
util.jsonschema: Lua <5.3 compat here too
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 09 May 2022 22:39:05 +0200 |
parent | 12132:4ff0d33dfb2b |
child | 12579:ca6a43fe0231 |
line wrap: on
line diff
--- a/util/jsonschema.lua Mon May 09 22:36:57 2022 +0200 +++ b/util/jsonschema.lua Mon May 09 22:39:05 2022 +0200 @@ -1,3 +1,6 @@ +local m_type = math.type or function (n) + return n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float"; +end; local json = require("util.json") local null = json.null; @@ -17,7 +20,7 @@ elseif schema == "array" and type(data) == "table" then return type(data) == "table" and (next(data) == nil or type((next(data, nil))) == "number") elseif schema == "integer" then - return math.type(data) == schema + return m_type(data) == schema elseif schema == "null" then return data == null else