MCPcopy
hub / github.com/ajv-validator/ajv / validateAdditionalItems

Function validateAdditionalItems

lib/vocabularies/applicator/additionalItems.ts:35–54  ·  view source on GitHub ↗
(cxt: KeywordCxt, items: AnySchema[])

Source from the content-addressed store, hash-verified

33}
34
35export 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
56export default def

Callers 2

codeFunction · 0.90
codeFunction · 0.85

Calls 10

_Function · 0.90
alwaysValidSchemaFunction · 0.90
notFunction · 0.90
constMethod · 0.80
setParamsMethod · 0.80
passMethod · 0.80
varMethod · 0.80
ifMethod · 0.80
okMethod · 0.80
validateItemsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…