MCPcopy Create free account
hub / github.com/json-editor/json-editor / validateArray

Function validateArray

docs/scripts/ajv-validator.js:5519–5541  ·  view source on GitHub ↗
(cxt)

Source from the content-addressed store, hash-verified

5517 }
5518 exports.usePattern = usePattern;
5519 function validateArray(cxt) {
5520 const { gen, data, keyword, it } = cxt;
5521 const valid = gen.name("valid");
5522 if (it.allErrors) {
5523 const validArr = gen.let("valid", true);
5524 validateItems(() => gen.assign(validArr, false));
5525 return validArr;
5526 }
5527 gen.var(valid, true);
5528 validateItems(() => gen.break());
5529 return valid;
5530 function validateItems(notValid) {
5531 const len = gen.const("len", (0, codegen_1._) `${data}.length`);
5532 gen.forRange("i", 0, len, (i) => {
5533 cxt.subschema({
5534 keyword,
5535 dataProp: i,
5536 dataPropType: util_1.Type.Num,
5537 }, valid);
5538 gen.if((0, codegen_1.not)(valid), notValid);
5539 });
5540 }
5541 }
5542 exports.validateArray = validateArray;
5543 function validateUnion(cxt) {
5544 const { gen, schema, keyword, it } = cxt;

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected