aboutsummaryrefslogtreecommitdiffstats
path: root/teal-src/util
diff options
context:
space:
mode:
Diffstat (limited to 'teal-src/util')
-rw-r--r--teal-src/util/jsonschema.tl14
1 files changed, 13 insertions, 1 deletions
diff --git a/teal-src/util/jsonschema.tl b/teal-src/util/jsonschema.tl
index 3f5b0f26..89a9b724 100644
--- a/teal-src/util/jsonschema.tl
+++ b/teal-src/util/jsonschema.tl
@@ -37,6 +37,7 @@ local record schema_t
format : string
-- arrays
+ prefixItems : { schema_t }
items : schema_t
contains : schema_t
maxItems : number
@@ -277,8 +278,19 @@ type_validators.table = function (schema : schema_t, data : any) : boolean
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