util.jsonschema: Lua <5.3 compat here too 0.12
authorKim Alvefur <zash@zash.se>
Mon, 09 May 2022 22:39:05 +0200
branch0.12
changeset 12504 88e1b94105ae
parent 12503 03e307952816
child 12505 042de4f0076e
child 12509 604bb5b8362d
util.jsonschema: Lua <5.3 compat here too
util/jsonschema.lua
--- 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