Comparison

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
parent 13084:87f646e353cf
child 13087:5d3e8a226840
comparison
equal deleted inserted replaced
13084:87f646e353cf 13085:0e17cb78264f
107 return false 107 return false
108 end 108 end
109 if schema.minLength and #data < schema.minLength then 109 if schema.minLength and #data < schema.minLength then
110 return false 110 return false
111 end 111 end
112 if schema.luaPattern and not data:match(schema.luaPattern) then
113 return false
114 end
112 end 115 end
113 116
114 if type(data) == "number" then 117 if type(data) == "number" then
115 if schema.multipleOf and (data == 0 or data % schema.multipleOf ~= 0) then 118 if schema.multipleOf and (data == 0 or data % schema.multipleOf ~= 0) then
116 return false 119 return false