Software /
code /
prosody
Diff
util/jsonschema.lua @ 13087:5d3e8a226840
util.jsonschema: Implement 'minContains' and 'maxContains'
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 23 Apr 2023 10:26:43 +0200 |
parent | 13085:0e17cb78264f |
child | 13088:0fbb2b3fd4c0 |
line wrap: on
line diff
--- a/util/jsonschema.lua Sat Apr 22 13:30:19 2023 +0200 +++ b/util/jsonschema.lua Sun Apr 23 10:26:43 2023 +0200 @@ -305,14 +305,13 @@ end if schema.contains ~= nil then - local found = false + local found = 0 for i = 1, #data do if validate(schema.contains, data[i], root) then - found = true - break + found = found + 1 end end - if not found then + if found < (schema.minContains or 1) or found > (schema.maxContains or math.huge) then return false end end