diff options
author | Kim Alvefur <zash@zash.se> | 2023-04-22 12:48:51 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2023-04-22 12:48:51 +0200 |
commit | 9c7c94ab73eb1e9fe78fc022805a06be0579d4b9 (patch) | |
tree | 87bb645be37abe5deb50f74ecbd421729d7f96c2 /teal-src | |
parent | 1dad83d28eafc84d2253eadf8ed58d6caefc78df (diff) | |
download | prosody-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 'teal-src')
-rw-r--r-- | teal-src/prosody/util/jsonschema.tl | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/teal-src/prosody/util/jsonschema.tl b/teal-src/prosody/util/jsonschema.tl index 75cfab92..8acb1309 100644 --- a/teal-src/prosody/util/jsonschema.tl +++ b/teal-src/prosody/util/jsonschema.tl @@ -98,6 +98,7 @@ local record json_schema_object -- for Lua luaPatternProperties: { string : schema_t } + luaPattern : string -- xml record xml_t @@ -225,6 +226,9 @@ function complex_validate (schema : json_schema_object, data : any, root : json_ 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 data is number then |