From 0e87c0f39678a40a8ee73aede2df6d5877d33580 Mon Sep 17 00:00:00 2001 From: Alex Liu Date: Sun, 1 Oct 2023 22:41:15 +0800 Subject: [PATCH] feat(core): `useField` return function that `validateField` --- packages/core/src/composables/useForm.ts | 1 + packages/core/src/types.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/core/src/composables/useForm.ts b/packages/core/src/composables/useForm.ts index 529b746..0972c5c 100644 --- a/packages/core/src/composables/useForm.ts +++ b/packages/core/src/composables/useForm.ts @@ -601,6 +601,7 @@ export function useForm< value: getFieldValue(name), attrs: getFieldAttrs(name), ...getFieldMeta(name), + validateField: () => validateField(toValue(name)), }; }; diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index ed62175..56cbdf1 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -64,6 +64,7 @@ export interface FieldRegisterOptions { export type UseFormRegisterReturn = FieldMeta & { value: WritableComputedRef; attrs: ComputedRef; + validateField(): Promise; }; export type SetFieldArrayValue = <