Software /
code /
prosody
Changeset
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 |
parents | 12499:03e307952816 |
children | 12501:042de4f0076e 12505:604bb5b8362d |
files | util/jsonschema.lua |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
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