diff --git a/src/index.ts b/src/index.ts index d1555b4..5c7fec7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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); diff --git a/src/types.ts b/src/types.ts index e2a3ffb..90c9c5d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -95,8 +95,8 @@ export interface NormalizedValidateError { } export type ValidateCallback = ( - errors: ValidateError[] | null, - fields?: Record | null + errors: NormalizedValidateError[] | null, + fields?: Record | null ) => void; export type ErrorCallback = (