Skip to content

Commit

Permalink
fix(appendErrors): incorrect type, it can take an array of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisre committed Mar 17, 2023
1 parent 1d72c6c commit f64a8fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/__tests__/logic/appendErrors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,27 @@ describe('appendErrors', () => {
undefined: true,
},
});

errors.test.types = {
...errors.test.types,
undefined: true,
};
expect(
appendErrors('test', true, errors, 'invalid_string', [
'uppercase',
'lowercase',
'number',
]),
).toEqual({
message: 'test',
type: 'required',
types: {
required: 'test',
min: 'test',
max: 'test',
undefined: true,
invalid_string: ['uppercase', 'lowercase', 'number'],
},
});
});
});
2 changes: 1 addition & 1 deletion src/types/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type ValidationValueMessage<
message: Message;
};

export type ValidateResult = Message | boolean | undefined;
export type ValidateResult = Message | Message[] | boolean | undefined;

export type Validate<TFieldValue, TFormValues> = (
value: TFieldValue,
Expand Down

0 comments on commit f64a8fd

Please sign in to comment.