(cxt: KeywordCxt, items: AnySchema[])
| 33 | } |
| 34 | |
| 35 | export function validateAdditionalItems(cxt: KeywordCxt, items: AnySchema[]): void { |
| 36 | const {gen, schema, data, keyword, it} = cxt |
| 37 | it.items = true |
| 38 | const len = gen.const("len", _`${data}.length`) |
| 39 | if (schema === false) { |
| 40 | cxt.setParams({len: items.length}) |
| 41 | cxt.pass(_`${len} <= ${items.length}`) |
| 42 | } else if (typeof schema == "object" && !alwaysValidSchema(it, schema)) { |
| 43 | const valid = gen.var("valid", _`${len} <= ${items.length}`) // TODO var |
| 44 | gen.if(not(valid), () => validateItems(valid)) |
| 45 | cxt.ok(valid) |
| 46 | } |
| 47 | |
| 48 | function validateItems(valid: Name): void { |
| 49 | gen.forRange("i", items.length, len, (i) => { |
| 50 | cxt.subschema({keyword, dataProp: i, dataPropType: Type.Num}, valid) |
| 51 | if (!it.allErrors) gen.if(not(valid), () => gen.break()) |
| 52 | }) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | export default def |
no test coverage detected
searching dependent graphs…