aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-05-09 22:39:05 +0200
committerKim Alvefur <zash@zash.se>2022-05-09 22:39:05 +0200
commit6a9efa5a52289b58401faf6e3deb7a2272dd323a (patch)
tree01584e644c411b2a5fd1cf4de207dc0f5c1c2a46 /util
parentd9de9b5627a4cce0fcad27ecc39ce62a9176b3b8 (diff)
downloadprosody-6a9efa5a52289b58401faf6e3deb7a2272dd323a.tar.gz
prosody-6a9efa5a52289b58401faf6e3deb7a2272dd323a.zip
util.jsonschema: Lua <5.3 compat here too
Diffstat (limited to 'util')
-rw-r--r--util/jsonschema.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/util/jsonschema.lua b/util/jsonschema.lua
index 65974a84..8286fa19 100644
--- a/util/jsonschema.lua
+++ b/util/jsonschema.lua
@@ -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 @@ local function simple_validate(schema, data)
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