Propagate CheckSchemaOptions to allow failFast to work as intended

This commit is contained in:
Michael B. Gale
2026-07-10 14:24:33 +01:00
parent 512bf6f1a3
commit 0b10dee3ee
2 changed files with 31 additions and 19 deletions

21
lib/entry-points.js generated
View File

@@ -144526,7 +144526,7 @@ function array(validator) {
};
return {
validate,
check: (val, path29) => {
check: (val, opts, path29) => {
const result = successfulCheckSchema();
if (!isArray(val)) {
result.valid = false;
@@ -144535,12 +144535,15 @@ function array(validator) {
let index2 = 0;
for (const e of val) {
const elementPath = `${path29}[${index2}]`;
const eResult = validator.check(e, `${elementPath}`);
const eResult = validator.check(e, opts, `${elementPath}`);
result.unknownKeys.push(...eResult.unknownKeys);
index2++;
if (!eResult.valid) {
result.valid = false;
result.invalidKeys.push(elementPath);
if (opts.failFast) {
return result;
}
continue;
}
}
@@ -144554,11 +144557,11 @@ function object(schema) {
validate: (val) => {
return isObject(val) && validateSchema(schema, val);
},
check: (val, path29) => {
check: (val, opts, path29) => {
if (!isObject(val)) {
return invalidCheckSchema();
}
return checkSchema(schema, val, {}, path29);
return checkSchema(schema, val, opts, path29);
},
required: true
};
@@ -144568,11 +144571,11 @@ function optionalOrNull(validator) {
validate: (val) => {
return val === void 0 || val === null || validator.validate(val);
},
check: (val, path29) => {
check: (val, opts, path29) => {
if (val === void 0 || val === null) {
return successfulCheckSchema();
}
return validator.check(val, path29);
return validator.check(val, opts, path29);
},
required: false
};
@@ -144582,11 +144585,11 @@ function optional(validator) {
validate: (val) => {
return val === void 0 || validator.validate(val);
},
check: (val, path29) => {
check: (val, opts, path29) => {
if (val === void 0) {
return successfulCheckSchema();
}
return validator.check(val, path29);
return validator.check(val, opts, path29);
},
required: false
};
@@ -144632,7 +144635,7 @@ function checkSchema(schema, obj, options = {}, path29 = "") {
continue;
}
if (hasKey) {
const checkResult = validator.check(obj[key], `${path29}.${key}`);
const checkResult = validator.check(obj[key], options, `${path29}.${key}`);
result.unknownKeys.push(...checkResult.unknownKeys);
result.invalidKeys.push(...checkResult.invalidKeys);
if (checkResult.invalidKeys.length > 0) {