vue-yup-wrapper-reactive
Version:
Vue 3 composable plugin that integrates Yup validation with Vue reactive system for easy and type-safe form validation
16 lines • 1.35 kB
TypeScript
import * as Yup from 'yup';
export declare const YUP: typeof Yup;
export declare const YUP_OBJECT: typeof Yup.object;
type FormValue = unknown;
type FormField<T extends FormValue> = [T, Yup.Schema<T>, string?];
type FormConfig = Record<string, FormField<FormValue>>;
export declare function useYupForm<T extends FormConfig>(config: T): {
form: import("vue").Reactive<{ [K in keyof T]: T[K][0]; }>;
errors: [Partial<Record<keyof T, string>> | Record<string, never>] extends [import("vue").Ref<any, any>] ? import("@vue/shared").IfAny<import("vue").Ref<any, any> & (Partial<Record<keyof T, string>> | Record<string, never>), import("vue").Ref<import("vue").Ref<any, any> & (Partial<Record<keyof T, string>> | Record<string, never>), import("vue").Ref<any, any> & (Partial<Record<keyof T, string>> | Record<string, never>)>, import("vue").Ref<any, any> & (Partial<Record<keyof T, string>> | Record<string, never>)> : import("vue").Ref<Record<string, never> | import("vue").UnwrapRef<Partial<Record<keyof T, string>>>, Partial<Record<keyof T, string>> | Record<string, never> | import("vue").UnwrapRef<Partial<Record<keyof T, string>>>>;
reset: () => void;
validate: () => Promise<boolean>;
getFieldLabel: (fieldKey: keyof T) => string;
fieldLabels: { [K_1 in keyof T]: string; };
};
export {};
//# sourceMappingURL=useForm.d.ts.map