Skip to content

Commit

Permalink
fix: provide yup object schema type to the useForm closes #2988
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Oct 18, 2020
1 parent 4d558d9 commit 29157f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComputedRef, Ref } from 'vue';
import { ObjectSchema } from 'yup';

export interface ValidationResult {
errors: string[];
Expand Down Expand Up @@ -34,7 +35,7 @@ export interface FormController {
unregister(field: any): void;
values: Record<string, any>;
fields: ComputedRef<Record<string, any>>;
schema?: Record<string, GenericValidateFunction | string | Record<string, any>>;
schema?: Record<string, GenericValidateFunction | string | Record<string, any>> | ObjectSchema;
validateSchema?: (shouldMutate?: boolean) => Promise<Record<string, ValidationResult>>;
setFieldValue: (path: string, value: any) => void;
setFieldError: (field: string, message: string) => void;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/useForm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { computed, ref, Ref, provide, reactive, onMounted, isRef, watch, ComputedRef } from 'vue';
import type { ValidationError } from 'yup';
import type { ObjectSchema, ValidationError } from 'yup';
import type { useField } from './useField';
import {
FieldMeta,
Expand All @@ -15,7 +15,7 @@ import { getFromPath, isYupValidator, keysOf, setInPath, unsetPath } from './uti
import { FormErrorsSymbol, FormInitialValues, FormSymbol } from './symbols';

interface FormOptions {
validationSchema?: Record<string, GenericValidateFunction | string | Record<string, any>>;
validationSchema?: Record<string, GenericValidateFunction | string | Record<string, any>> | ObjectSchema;
initialValues?: MaybeReactive<Record<string, any>>;
validateOnMount?: boolean;
}
Expand Down

0 comments on commit 29157f7

Please sign in to comment.