vue-yup-wrapper-reactive
Version:
Vue 3 composable plugin that integrates Yup validation with Vue reactive system for easy and type-safe form validation
29 lines (25 loc) • 1.49 kB
TypeScript
import * as _vue_shared from '@vue/shared';
import * as vue from 'vue';
import * as Yup from 'yup';
export { Schema } from 'yup';
declare const YUP: typeof Yup;
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>>;
declare function useYupForm<T extends FormConfig>(config: T): {
form: vue.Reactive<{ [K in keyof T]: T[K][0]; }>;
errors: [Partial<Record<keyof T, string>> | Record<string, never>] extends [vue.Ref<any, any>] ? _vue_shared.IfAny<vue.Ref<any, any> & (Partial<Record<keyof T, string>> | Record<string, never>), vue.Ref<vue.Ref<any, any> & (Partial<Record<keyof T, string>> | Record<string, never>), vue.Ref<any, any> & (Partial<Record<keyof T, string>> | Record<string, never>)>, vue.Ref<any, any> & (Partial<Record<keyof T, string>> | Record<string, never>)> : vue.Ref<Record<string, never> | vue.UnwrapRef<Partial<Record<keyof T, string>>>, Partial<Record<keyof T, string>> | Record<string, never> | vue.UnwrapRef<Partial<Record<keyof T, string>>>>;
reset: () => void;
validate: () => Promise<boolean>;
getFieldLabel: (fieldKey: keyof T) => string;
fieldLabels: { [K_1 in keyof T]: string; };
};
declare const version = "1.0.0";
declare const pluginInfo: {
name: string;
version: string;
description: string;
author: string;
};
export { YUP, YUP_OBJECT, pluginInfo, useYupForm, version };