Skip to content

Commit

Permalink
fix: update for other resolvers with new option (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebill1049 authored May 17, 2022
1 parent 259b4dc commit c560af3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 5 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@

## API

`resolver(schema: object, schemaOptions?: object, resolverOptions: { mode: 'async' | 'sync' })`
```
type Options = {
mode: 'async' | 'sync',
rawValues?: boolean
}
resolver(schema: object, schemaOptions?: object, resolverOptions: Options)
````

| | type | Required | Description |
| --------------- | -------- | -------- | --------------------------------------------- |
Expand Down
2 changes: 1 addition & 1 deletion class-validator/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ClassConstructor } from 'class-transformer';
export type Resolver = <T extends { [_: string]: any }>(
schema: ClassConstructor<T>,
schemaOptions?: ValidatorOptions,
resolverOptions?: { mode?: 'async' | 'sync' },
resolverOptions?: { mode?: 'async' | 'sync', rawValues?: boolean; },
) => <TFieldValues extends FieldValues, TContext>(
values: UnpackNestedValue<TFieldValues>,
context: TContext | undefined,
Expand Down
1 change: 1 addition & 0 deletions nope/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Context = Parameters<NopeObject['validate']>[1];
export type Resolver = <T extends NopeObject>(
schema: T,
schemaOptions?: ValidateOptions,
resolverOptions?: { mode?: 'async' | 'sync', rawValues?: boolean; },
) => <TFieldValues extends FieldValues, TContext extends Context>(
values: UnpackNestedValue<TFieldValues>,
context: TContext | undefined,
Expand Down
1 change: 1 addition & 0 deletions typanion/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ type RHFResolver = <TFieldValues extends FieldValues, TContext>(
export type Resolver = <UnknownValidator extends AnyStrictValidator>(
validator: UnknownValidator,
validatorOptions?: ValidateOptions,
resolverOptions?: { mode?: 'async' | 'sync', rawValues?: boolean; },
)=> RHFResolver
2 changes: 1 addition & 1 deletion vest/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type ICreateResult = ReturnType<typeof Vest.create>;
export type Resolver = (
schema: ICreateResult,
schemaOptions?: never,
factoryOptions?: { mode?: 'async' | 'sync' },
factoryOptions?: { mode?: 'async' | 'sync', rawValues?: boolean; },
) => <TFieldValues extends FieldValues, TContext>(
values: UnpackNestedValue<TFieldValues>,
context: TContext | undefined,
Expand Down
2 changes: 1 addition & 1 deletion yup/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Options<T extends Yup.AnyObjectSchema | Lazy<any>> = Parameters<
export type Resolver = <T extends Yup.AnyObjectSchema | Lazy<any>>(
schema: T,
schemaOptions?: Options<T>,
factoryOptions?: { mode?: 'async' | 'sync' },
factoryOptions?: { mode?: 'async' | 'sync', rawValues?: boolean; },
) => <TFieldValues extends FieldValues, TContext>(
values: UnpackNestedValue<TFieldValues>,
context: TContext | undefined,
Expand Down
2 changes: 1 addition & 1 deletion yup/src/yup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const yupResolver: Resolver =
options.shouldUseNativeValidation && validateFieldsNatively({}, options);

return {
values: result,
values: resolverOptions.rawValues ? values : result,
errors: {},
};
} catch (e: any) {
Expand Down

0 comments on commit c560af3

Please sign in to comment.