Skip to content

Commit

Permalink
fix: improve ValidateCallback type
Browse files Browse the repository at this point in the history
  • Loading branch information
YSMJ1994 committed Feb 4, 2024
1 parent e1d5606 commit 511db1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ class Schema {
errors = ([] as string[]).concat(rule.message);
}

errors = errors.map(complementError(rule));
const normalizeErrors = errors.map(complementError(rule));

next(errors as NormalizedValidateError[]);
next(normalizeErrors);
};

const res = rule.validator(rule, data.value, cb, this._options);
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export interface NormalizedValidateError {
}

export type ValidateCallback = (
errors: ValidateError[] | null,
fields?: Record<string, ValidateError[]> | null
errors: NormalizedValidateError[] | null,
fields?: Record<string, NormalizedValidateError[]> | null
) => void;

export type ErrorCallback = (
Expand Down

0 comments on commit 511db1d

Please sign in to comment.