From e6e3d121441433aff62d308c831adaa2b1feaa21 Mon Sep 17 00:00:00 2001 From: Daniel Cousens <413395+dcousens@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:48:07 +1000 Subject: [PATCH] tidy up and update comments --- packages/core/src/fields/resolve-hooks.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/core/src/fields/resolve-hooks.ts b/packages/core/src/fields/resolve-hooks.ts index 5179c442bcc..e093cfc081f 100644 --- a/packages/core/src/fields/resolve-hooks.ts +++ b/packages/core/src/fields/resolve-hooks.ts @@ -28,13 +28,10 @@ function resolveValidateHooks ({ validateDelete }: FieldHooks): Exclude["validate"], Function> | undefined { if (!validate && !validateInput && !validateDelete) return - - const isFnValidate = typeof validate === 'function' - return { - create: merge(validateInput, isFnValidate ? validate : validate?.create), - update: merge(validateInput, isFnValidate ? validate : validate?.update), - delete: merge(validateDelete, isFnValidate ? validate : validate?.delete), + create: merge(validateInput, typeof validate === 'function' ? validate : validate?.create), + update: merge(validateInput, typeof validate === 'function' ? validate : validate?.update), + delete: merge(validateDelete, typeof validate === 'function' ? validate : validate?.delete), } } @@ -45,7 +42,7 @@ export function mergeFieldHooks ( if (hooks === undefined) return builtin if (builtin === undefined) return hooks - const builtinValidate = resolveValidateHooks(builtin) + const builtinValidate = resolveValidateHooks(builtin) const hooksValidate = resolveValidateHooks(hooks) return { ...hooks, @@ -59,10 +56,8 @@ export function mergeFieldHooks ( delete: merge(builtinValidate?.delete, hooksValidate?.delete) } : undefined, - // @deprecated, TODO: remove in breaking change - // set deprecated hooks to undefined so they don't get passed through from - // user-defined hooks - validateInput: undefined, - validateDelete: undefined, + // TODO: remove in breaking change + validateInput: undefined, // prevent continuation + validateDelete: undefined, // prevent continuation } satisfies FieldHooks }