We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
invalidKeys
array
1 parent 89343ee commit 3f1e4daCopy full SHA for 3f1e4da
1 file changed
src/json/index.ts
@@ -104,12 +104,18 @@ export function array<T>(validator: Validator<T>) {
104
const elementPath = `${path}[${index}]`;
105
const eResult = validator.check(e, opts, `${elementPath}`);
106
107
+ result.invalidKeys.push(...eResult.invalidKeys);
108
result.unknownKeys.push(...eResult.unknownKeys);
109
index++;
110
111
if (!eResult.valid) {
112
result.valid = false;
- result.invalidKeys.push(elementPath);
113
+
114
+ // Add the element path to `invalidKeys` if we didn't get
115
+ // any more specific ones from the element validator.
116
+ if (eResult.invalidKeys.length === 0) {
117
+ result.invalidKeys.push(elementPath);
118
+ }
119
120
if (opts.failFast) {
121
return result;
0 commit comments