util.jsonschema: Implement the "prefixItems" keyword

This may have been what got me confused about "items" being an array.
This commit is contained in:
Kim Alvefur 2021-03-09 02:36:08 +01:00
parent ce4040e109
commit da85d37bcb
2 changed files with 25 additions and 2 deletions

View file

@ -197,8 +197,19 @@ type_validators.table = function(schema, data)
return true
end
local p = 0
if schema.prefixItems then
for i, s in ipairs(schema.prefixItems) do
if validate(s, data[i]) then
p = i
else
return false
end
end
end
if schema.items then
for i = 1, #data do
for i = p + 1, #data do
if not validate(schema.items, data[i]) then
return false
end