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

Function validateArray

lib/vocabularies/code.ts:107–133  ·  view source on GitHub ↗
(cxt: KeywordCxt)

Source from the content-addressed store, hash-verified

105}
106
107export function validateArray(cxt: KeywordCxt): Name {
108 const {gen, data, keyword, it} = cxt
109 const valid = gen.name("valid")
110 if (it.allErrors) {
111 const validArr = gen.let("valid", true)
112 validateItems(() => gen.assign(validArr, false))
113 return validArr
114 }
115 gen.var(valid, true)
116 validateItems(() => gen.break())
117 return valid
118
119 function validateItems(notValid: () => void): void {
120 const len = gen.const("len", _`${data}.length`)
121 gen.forRange("i", 0, len, (i) => {
122 cxt.subschema(
123 {
124 keyword,
125 dataProp: i,
126 dataPropType: Type.Num,
127 },
128 valid
129 )
130 gen.if(not(valid), notValid)
131 })
132 }
133}
134
135export function validateUnion(cxt: KeywordCxt): void {
136 const {gen, schema, keyword, it} = cxt

Callers 3

codeFunction · 0.90
codeFunction · 0.90
codeFunction · 0.90

Calls 6

letMethod · 0.80
assignMethod · 0.80
varMethod · 0.80
breakMethod · 0.80
validateItemsFunction · 0.70
nameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…