aboutsummaryrefslogtreecommitdiffstats
path: root/util/jsonschema.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-04-22 12:48:51 +0200
committerKim Alvefur <zash@zash.se>2023-04-22 12:48:51 +0200
commit9c7c94ab73eb1e9fe78fc022805a06be0579d4b9 (patch)
tree87bb645be37abe5deb50f74ecbd421729d7f96c2 /util/jsonschema.lua
parent1dad83d28eafc84d2253eadf8ed58d6caefc78df (diff)
downloadprosody-9c7c94ab73eb1e9fe78fc022805a06be0579d4b9.tar.gz
prosody-9c7c94ab73eb1e9fe78fc022805a06be0579d4b9.zip
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.
Diffstat (limited to 'util/jsonschema.lua')
-rw-r--r--util/jsonschema.lua3
1 files changed, 3 insertions, 0 deletions
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