Comparison

teal-src/util/jsonschema.tl @ 11442:95f0d77175ca

util.jsonschema: Implement the "contains" keyword And apparently I had mistaken this for an array
author Kim Alvefur <zash@zash.se>
date Tue, 09 Mar 2021 02:35:00 +0100
parent 11441:75a280e6e046
child 11443:a526abef61e6
comparison
equal deleted inserted replaced
11441:75a280e6e046 11442:95f0d77175ca
36 pattern : string 36 pattern : string
37 format : string 37 format : string
38 38
39 -- arrays 39 -- arrays
40 items : schema_t 40 items : schema_t
41 contains : { schema_t } 41 contains : schema_t
42 maxItems : number 42 maxItems : number
43 minItems : number 43 minItems : number
44 uniqueItems : boolean 44 uniqueItems : boolean
45 maxContains : number 45 maxContains : number
46 minContains : number 46 minContains : number
283 return false 283 return false
284 end 284 end
285 end 285 end
286 end 286 end
287 287
288 if schema.contains then
289 local found = false
290 for i = 1, #data do
291 if validate(schema.contains, data[i]) then
292 found = true
293 break
294 end
295 end
296 if not found then
297 return false
298 end
299 end
300
288 return true 301 return true
289 end 302 end
290 return false 303 return false
291 end 304 end
292 305