From c8b5d7e99aa6df7aea56540e6a8ecf3d3bf513b4 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 17 Jun 2023 17:12:54 +0200 Subject: util.jsonschema: Silence Teal warnings about counting items in tables Teal thinks that these are key-value maps which are always of length zero, but that is not the case. --- util/jsonschema.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'util') diff --git a/util/jsonschema.lua b/util/jsonschema.lua index c67fb744..316fe976 100644 --- a/util/jsonschema.lua +++ b/util/jsonschema.lua @@ -199,11 +199,11 @@ function complex_validate(schema, data, root) if type(data) == "table" then - if schema.maxItems and #data > schema.maxItems then + if schema.maxItems and #(data) > schema.maxItems then return false end - if schema.minItems and #data < schema.minItems then + if schema.minItems and #(data) < schema.minItems then return false end @@ -303,7 +303,7 @@ function complex_validate(schema, data, root) end if schema.items ~= nil then - for i = p + 1, #data do + for i = p + 1, #(data) do if not validate(schema.items, data[i], root) then return false end @@ -312,7 +312,7 @@ function complex_validate(schema, data, root) if schema.contains ~= nil then local found = 0 - for i = 1, #data do + for i = 1, #(data) do if validate(schema.contains, data[i], root) then found = found + 1 end -- cgit v1.2.3