aboutsummaryrefslogtreecommitdiffstats
path: root/teal-src
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-06-17 17:12:54 +0200
committerKim Alvefur <zash@zash.se>2023-06-17 17:12:54 +0200
commitc8b5d7e99aa6df7aea56540e6a8ecf3d3bf513b4 (patch)
treef087d9a46558d403756b00863e0a1585116eefc7 /teal-src
parent97f85e98f2bbfc55c3786e8bdef33afc4afa08a9 (diff)
downloadprosody-c8b5d7e99aa6df7aea56540e6a8ecf3d3bf513b4.tar.gz
prosody-c8b5d7e99aa6df7aea56540e6a8ecf3d3bf513b4.zip
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.
Diffstat (limited to 'teal-src')
-rw-r--r--teal-src/prosody/util/jsonschema.tl8
1 files changed, 4 insertions, 4 deletions
diff --git a/teal-src/prosody/util/jsonschema.tl b/teal-src/prosody/util/jsonschema.tl
index a1dd3cae..0971c548 100644
--- a/teal-src/prosody/util/jsonschema.tl
+++ b/teal-src/prosody/util/jsonschema.tl
@@ -320,11 +320,11 @@ function complex_validate (schema : json_schema_object, data : any, root : json_
-- validations in this block, which could be useful for validating Lua
-- tables
- if schema.maxItems and #data > schema.maxItems then
+ if schema.maxItems and #(data as {any}) > schema.maxItems then
return false
end
- if schema.minItems and #data < schema.minItems then
+ if schema.minItems and #(data as {any}) < schema.minItems then
return false
end
@@ -428,7 +428,7 @@ function complex_validate (schema : json_schema_object, data : any, root : json_
end
if schema.items ~= nil then
- for i = p+1, #data do
+ for i = p+1, #(data as {any}) do
if not validate(schema.items, data[i], root) then
return false
end
@@ -437,7 +437,7 @@ function complex_validate (schema : json_schema_object, data : any, root : json_
if schema.contains ~= nil then
local found = 0
- for i = 1, #data do
+ for i = 1, #(data as {any}) do
if validate(schema.contains, data[i], root) then
found = found + 1
end