From 9c7c94ab73eb1e9fe78fc022805a06be0579d4b9 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 22 Apr 2023 12:48:51 +0200 Subject: util.jsonschema: Implement 'luaPattern' - Lua variant of 'pattern' Like 'pattern' but uses Lua patterns instead of Regular Expressions, since only a subset of regex are also valid Lua patterns. --- util/jsonschema.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util') diff --git a/util/jsonschema.lua b/util/jsonschema.lua index c65470fd..2a6d6bbf 100644 --- a/util/jsonschema.lua +++ b/util/jsonschema.lua @@ -109,6 +109,9 @@ function complex_validate(schema, data, root) if schema.minLength and #data < schema.minLength then return false end + if schema.luaPattern and not data:match(schema.luaPattern) then + return false + end end if type(data) == "number" then -- cgit v1.2.3