-
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pass field names and a context as arguments to a Vest suite (#584)
- Loading branch information
Showing
3 changed files
with
26 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
import { | ||
FieldValues, | ||
FieldName, | ||
ResolverOptions, | ||
ResolverResult, | ||
} from 'react-hook-form'; | ||
import * as Vest from 'vest'; | ||
|
||
export type ICreateResult = ReturnType<typeof Vest.create>; | ||
export type ICreateResult<TValues extends FieldValues = FieldValues, TContext = any> = ReturnType< | ||
typeof Vest.create<(values: TValues, names?: FieldName<TValues>[], context?: TContext) => void> | ||
>; | ||
|
||
export type Resolver = ( | ||
schema: ICreateResult, | ||
export type Resolver = <TValues extends FieldValues, TContext>( | ||
schema: ICreateResult<TValues, TContext>, | ||
schemaOptions?: never, | ||
factoryOptions?: { mode?: 'async' | 'sync', rawValues?: boolean; }, | ||
) => <TFieldValues extends FieldValues, TContext>( | ||
values: TFieldValues, | ||
) => ( | ||
values: TValues, | ||
context: TContext | undefined, | ||
options: ResolverOptions<TFieldValues>, | ||
) => Promise<ResolverResult<TFieldValues>>; | ||
options: ResolverOptions<TValues>, | ||
) => Promise<ResolverResult<TValues>>; | ||
|
||
export type VestErrors = Record<string, string[]>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters