aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--teal-src/prosody/util/jsonschema.tl4
-rw-r--r--util/jsonschema.lua3
2 files changed, 7 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
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