mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Propagate and prefer invalidKeys from element validator in array validator
This commit is contained in:
@@ -104,12 +104,18 @@ export function array<T>(validator: Validator<T>) {
|
||||
const elementPath = `${path}[${index}]`;
|
||||
const eResult = validator.check(e, opts, `${elementPath}`);
|
||||
|
||||
result.invalidKeys.push(...eResult.invalidKeys);
|
||||
result.unknownKeys.push(...eResult.unknownKeys);
|
||||
index++;
|
||||
|
||||
if (!eResult.valid) {
|
||||
result.valid = false;
|
||||
result.invalidKeys.push(elementPath);
|
||||
|
||||
// Add the element path to `invalidKeys` if we didn't get
|
||||
// any more specific ones from the element validator.
|
||||
if (eResult.invalidKeys.length === 0) {
|
||||
result.invalidKeys.push(elementPath);
|
||||
}
|
||||
|
||||
if (opts.failFast) {
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user