diff --git a/packages/type/src/serializer.ts b/packages/type/src/serializer.ts index 6feffca3f..661682bd4 100644 --- a/packages/type/src/serializer.ts +++ b/packages/type/src/serializer.ts @@ -1502,7 +1502,6 @@ export function typeGuardArray(elementType: Type, state: TemplateState) { ${v} = iterableSize(${state.accessor}) === 0; for (const ${item} of ${state.accessor}) { ${executeTemplates(state.fork(v, item).extendPath(new RuntimeCode(i)), elementType)} - if (!${v}) break; ${i}++; } } else if (${state.isValidation()}) { diff --git a/packages/type/tests/validation.spec.ts b/packages/type/tests/validation.spec.ts index 256648e1e..357b75185 100644 --- a/packages/type/tests/validation.spec.ts +++ b/packages/type/tests/validation.spec.ts @@ -354,3 +354,17 @@ test('speed', () => { // but inline vs ref must not be slower than 2.5 times. // expect(ratio).toBeLessThan(2.5); }); + +test('array with multiple errors', () => { + interface Skill { + level: number & Positive; + } + + const errors = validate>([{level: -1}, {level: -1}]); + console.log(errors); + + expect(errors).toEqual([ + {code: 'positive', message: 'Number needs to be positive', path: '0.level', value: -1}, + {code: 'positive', message: 'Number needs to be positive', path: '1.level', value: -1} + ]); +});