diff util/jsonschema.lua @ 13085:0e17cb78264f

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.
author Kim Alvefur <zash@zash.se>
date Sat, 22 Apr 2023 12:48:51 +0200
parents 87f646e353cf
children 5d3e8a226840
line wrap: on
line diff
--- a/util/jsonschema.lua	Sat Apr 22 12:14:29 2023 +0200
+++ b/util/jsonschema.lua	Sat Apr 22 12:48:51 2023 +0200
@@ -109,6 +109,9 @@
 		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