Skip to content

Commit

Permalink
feat(validateFields): add message to reject error type
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyunhe committed Jan 15, 2025
1 parent 811792a commit 11349b9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export type RuleObject = AggregationRule | ArrayRule;
export type Rule = RuleObject | RuleRender;

export interface ValidateErrorEntity<Values = any> {
message: string;
values: Values;
errorFields: { name: InternalNamePath; errors: string[] }[];
outOfDate: boolean;
Expand Down
2 changes: 2 additions & 0 deletions src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,9 @@ export class FormStore {
})
.catch((results: { name: InternalNamePath; errors: string[] }[]) => {
const errorList = results.filter(result => result && result.errors.length);
const errorMessage = errorList[0]?.errors?.[0];
return Promise.reject({
message: errorMessage,
values: this.getFieldsValue(namePathList),
errorFields: errorList,
outOfDate: this.lastValidatePromise !== summaryPromise,
Expand Down

0 comments on commit 11349b9

Please sign in to comment.