From ce4040e1091705d94bb46c59dcd0cc16edde702e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 9 Mar 2021 02:35:00 +0100 Subject: util.jsonschema: Implement the "contains" keyword And apparently I had mistaken this for an array --- util/jsonschema.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'util/jsonschema.lua') diff --git a/util/jsonschema.lua b/util/jsonschema.lua index b285feb4..4ace2d2d 100644 --- a/util/jsonschema.lua +++ b/util/jsonschema.lua @@ -205,6 +205,19 @@ type_validators.table = function(schema, data) end end + if schema.contains then + local found = false + for i = 1, #data do + if validate(schema.contains, data[i]) then + found = true + break + end + end + if not found then + return false + end + end + return true end return false -- cgit v1.2.3