Socket
Socket
Sign inDemoInstall

@hookform/resolvers

Package Overview
Dependencies
Maintainers
3
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hookform/resolvers - npm Package Compare versions

Comparing version 2.8.1 to 2.8.2

4

class-validator/dist/types.d.ts

@@ -6,4 +6,4 @@ import { FieldValues, ResolverOptions, ResolverResult, UnpackNestedValue } from 'react-hook-form';

[_: string]: any;
}, TFieldValues extends FieldValues, TContext>(schema: ClassConstructor<T>, schemaOptions?: ValidatorOptions, resolverOptions?: {
}>(schema: ClassConstructor<T>, schemaOptions?: ValidatorOptions, resolverOptions?: {
mode?: 'async' | 'sync';
}) => (values: UnpackNestedValue<TFieldValues>, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<ResolverResult<TFieldValues>>;
}) => <TFieldValues extends FieldValues, TContext>(values: UnpackNestedValue<TFieldValues>, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<ResolverResult<TFieldValues>>;

@@ -10,11 +10,7 @@ import {

export type Resolver = <
T extends { [_: string]: any },
TFieldValues extends FieldValues,
TContext,
>(
export type Resolver = <T extends { [_: string]: any }>(
schema: ClassConstructor<T>,
schemaOptions?: ValidatorOptions,
resolverOptions?: { mode?: 'async' | 'sync' },
) => (
) => <TFieldValues extends FieldValues, TContext>(
values: UnpackNestedValue<TFieldValues>,

@@ -21,0 +17,0 @@ context: TContext | undefined,

@@ -37,3 +37,3 @@ import type { FieldErrors } from 'react-hook-form';

};
} catch (error) {
} catch (error: any) {
return {

@@ -40,0 +40,0 @@ values: {},

@@ -1,2 +0,2 @@

import { FieldError, FieldErrors, ResolverOptions, FieldValues } from 'react-hook-form';
export declare const toNestError: <TFieldValues extends FieldValues>(errors: Record<string, FieldError>, options: ResolverOptions<TFieldValues>) => import("react-hook-form").DeepMap<import("react-hook-form").DeepPartial<TFieldValues>, FieldError>;
import { FieldError, FieldErrors, ResolverOptions } from 'react-hook-form';
export declare const toNestError: <TFieldValues>(errors: Record<string, FieldError>, options: ResolverOptions<TFieldValues>) => import("react-hook-form").DeepMap<import("react-hook-form").DeepPartial<import("react-hook-form").UnionLike<TFieldValues>>, FieldError>;
import * as t from 'io-ts';
import { FieldError, ResolverOptions, ResolverResult, UnpackNestedValue } from 'react-hook-form';
export declare type Resolver = <TFieldValues, TInput extends unknown = unknown, TContext extends object = object>(codec: t.Decoder<TInput, UnpackNestedValue<TFieldValues>>) => (values: TInput, _context: TContext | undefined, options: ResolverOptions<TFieldValues>) => ResolverResult<TFieldValues>;
import { FieldError, FieldValues, ResolverOptions, ResolverResult, UnpackNestedValue } from 'react-hook-form';
export declare type Resolver = <T, TFieldValues, TContext>(codec: t.Decoder<FieldValues, T>) => (values: UnpackNestedValue<TFieldValues>, _context: TContext | undefined, options: ResolverOptions<TFieldValues>) => ResolverResult<TFieldValues>;
export declare type ErrorObject = Record<string, FieldError>;

@@ -5,0 +5,0 @@ export declare type FieldErrorWithPath = FieldError & {

@@ -6,3 +6,2 @@ import * as Either from 'fp-ts/lib/Either';

import { Resolver } from './types';
import { FieldErrors } from 'react-hook-form';

@@ -30,6 +29,6 @@ export const ioTsResolver: Resolver = (codec) => (values, _context, options) =>

values,
errors: {} as FieldErrors<any>,
};
errors: {},
} as any;
},
),
);

@@ -1,5 +0,5 @@

/* eslint-disable @typescript-eslint/ban-types */
import * as t from 'io-ts';
import {
FieldError,
FieldValues,
ResolverOptions,

@@ -10,10 +10,6 @@ ResolverResult,

export type Resolver = <
TFieldValues,
TInput extends unknown = unknown,
TContext extends object = object,
>(
codec: t.Decoder<TInput, UnpackNestedValue<TFieldValues>>,
export type Resolver = <T, TFieldValues, TContext>(
codec: t.Decoder<FieldValues, T>,
) => (
values: TInput,
values: UnpackNestedValue<TFieldValues>,
_context: TContext | undefined,

@@ -20,0 +16,0 @@ options: ResolverOptions<TFieldValues>,

@@ -1,5 +0,5 @@

import { ResolverOptions, ResolverResult, UnpackNestedValue } from 'react-hook-form';
import { FieldValues, ResolverOptions, ResolverResult, UnpackNestedValue } from 'react-hook-form';
import type { AsyncValidationOptions, Schema } from 'joi';
export declare type Resolver = <T extends Schema, TFieldValues, TContext>(schema: T, schemaOptions?: AsyncValidationOptions, factoryOptions?: {
export declare type Resolver = <T extends Schema>(schema: T, schemaOptions?: AsyncValidationOptions, factoryOptions?: {
mode?: 'async' | 'sync';
}) => (values: UnpackNestedValue<TFieldValues>, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<ResolverResult<TFieldValues>>;
}) => <TFieldValues extends FieldValues, TContext>(values: UnpackNestedValue<TFieldValues>, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<ResolverResult<TFieldValues>>;
import {
FieldValues,
ResolverOptions,

@@ -8,7 +9,7 @@ ResolverResult,

export type Resolver = <T extends Schema, TFieldValues, TContext>(
export type Resolver = <T extends Schema>(
schema: T,
schemaOptions?: AsyncValidationOptions,
factoryOptions?: { mode?: 'async' | 'sync' },
) => (
) => <TFieldValues extends FieldValues, TContext>(
values: UnpackNestedValue<TFieldValues>,

@@ -15,0 +16,0 @@ context: TContext | undefined,

@@ -1,6 +0,6 @@

import type { ResolverOptions, ResolverResult, UnpackNestedValue } from 'react-hook-form';
import type { FieldValues, ResolverOptions, ResolverResult, UnpackNestedValue } from 'react-hook-form';
import type { NopeObject } from 'nope-validator/lib/cjs/NopeObject';
declare type ValidateOptions = Parameters<NopeObject['validate']>[2];
declare type Context = Parameters<NopeObject['validate']>[1];
export declare type Resolver = <T extends NopeObject, TFieldValues, TContext extends Context>(schema: T, schemaOptions?: ValidateOptions) => (values: UnpackNestedValue<TFieldValues>, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => ResolverResult<TFieldValues>;
export declare type Resolver = <T extends NopeObject>(schema: T, schemaOptions?: ValidateOptions) => <TFieldValues extends FieldValues, TContext extends Context>(values: UnpackNestedValue<TFieldValues>, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => ResolverResult<TFieldValues>;
export {};
import type {
FieldValues,
ResolverOptions,

@@ -11,10 +12,6 @@ ResolverResult,

export type Resolver = <
T extends NopeObject,
TFieldValues,
TContext extends Context,
>(
export type Resolver = <T extends NopeObject>(
schema: T,
schemaOptions?: ValidateOptions,
) => (
) => <TFieldValues extends FieldValues, TContext extends Context>(
values: UnpackNestedValue<TFieldValues>,

@@ -21,0 +18,0 @@ context: TContext | undefined,

{
"name": "@hookform/resolvers",
"amdName": "hookformResolvers",
"version": "2.8.1",
"version": "2.8.2",
"description": "React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts, Nope, computed-types and Typanion",

@@ -168,8 +168,8 @@ "main": "dist/resolvers.js",

"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^12.0.0",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.2.1",
"@types/jest": "^27.0.0",
"@types/react": "^17.0.17",
"@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.25.0",
"@types/jest": "^27.0.2",
"@types/react": "^17.0.27",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"check-export-map": "^1.1.1",

@@ -185,5 +185,5 @@ "class-transformer": "^0.4.0",

"io-ts-types": "^0.5.16",
"jest": "^27.0.6",
"jest": "^27.2.4",
"joi": "^17.4.2",
"lint-staged": "^11.1.2",
"lint-staged": "^11.2.0",
"microbundle": "^0.13.3",

@@ -197,3 +197,3 @@ "monocle-ts": "^2.3.10",

"react-dom": "^17.0.2",
"react-hook-form": "7.15.0",
"react-hook-form": "7.17.1",
"reflect-metadata": "^0.1.13",

@@ -203,6 +203,6 @@ "superstruct": "^0.15.2",

"typanion": "^3.3.2",
"typescript": "^4.3.2",
"typescript": "^4.4.3",
"vest": "^3.2.5",
"yup": "^0.32.9",
"zod": "^3.7.1"
"zod": "^3.9.8"
},

@@ -209,0 +209,0 @@ "peerDependencies": {

@@ -53,3 +53,3 @@ <div align="center">

age: yup.number().required(),
});
}).required();

@@ -56,0 +56,0 @@ const App = () => {

@@ -1,5 +0,5 @@

import { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
import { FieldValues, ResolverOptions, ResolverResult, UnpackNestedValue } from 'react-hook-form';
import { validate, Struct } from 'superstruct';
declare type Options = Parameters<typeof validate>[2];
export declare type Resolver = <TFieldValues extends FieldValues, TContext extends object = object>(schema: Struct<TFieldValues, any>, factoryOptions?: Options) => (values: unknown, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => ResolverResult<TFieldValues>;
export declare type Resolver = <T extends Struct<any, any>>(schema: T, factoryOtions?: Options) => <TFieldValues extends FieldValues, TContext>(values: UnpackNestedValue<TFieldValues>, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => ResolverResult<TFieldValues>;
export {};

@@ -1,2 +0,2 @@

import { FieldError, FieldErrors } from 'react-hook-form';
import { FieldError } from 'react-hook-form';
import { toNestError, validateFieldsNatively } from '@hookform/resolvers';

@@ -24,6 +24,3 @@

values: {},
errors: toNestError(
parseErrorSchema(result[0]),
options,
) as FieldErrors<any>,
errors: toNestError(parseErrorSchema(result[0]), options),
};

@@ -36,4 +33,4 @@ }

values: result[1],
errors: {} as FieldErrors<any>,
errors: {},
};
};

@@ -1,3 +0,7 @@

/* eslint-disable @typescript-eslint/ban-types */
import { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
import {
FieldValues,
ResolverOptions,
ResolverResult,
UnpackNestedValue,
} from 'react-hook-form';
import { validate, Struct } from 'superstruct';

@@ -7,12 +11,9 @@

export type Resolver = <
TFieldValues extends FieldValues,
TContext extends object = object,
>(
schema: Struct<TFieldValues, any>,
factoryOptions?: Options,
) => (
values: unknown,
export type Resolver = <T extends Struct<any, any>>(
schema: T,
factoryOtions?: Options,
) => <TFieldValues extends FieldValues, TContext>(
values: UnpackNestedValue<TFieldValues>,
context: TContext | undefined,
options: ResolverOptions<TFieldValues>,
) => ResolverResult<TFieldValues>;

@@ -1,6 +0,6 @@

import type { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
import { ValidationState, StrictValidator } from 'typanion';
import type { FieldValues, ResolverOptions, ResolverResult, UnpackNestedValue } from 'react-hook-form';
import { ValidationState, AnyStrictValidator } from 'typanion';
declare type ValidateOptions = Pick<ValidationState, 'coercions' | 'coercion'>;
declare type RHFResolver<TFieldValues extends FieldValues, TInput = unknown, TContext extends Object = object> = (values: TInput, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => ResolverResult<TFieldValues>;
export declare type Resolver = <TInput extends FieldValues = FieldValues, TFieldValues extends TInput = TInput, TContext extends object = object>(validator: StrictValidator<TInput, TFieldValues>, validatorOptions?: ValidateOptions) => RHFResolver<TFieldValues, TInput, TContext>;
declare type RHFResolver = <TFieldValues extends FieldValues, TContext>(values: UnpackNestedValue<TFieldValues>, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => ResolverResult<TFieldValues>;
export declare type Resolver = <UnknownValidator extends AnyStrictValidator>(validator: UnknownValidator, validatorOptions?: ValidateOptions) => RHFResolver;
export {};

@@ -37,9 +37,6 @@ import type { FieldErrors } from 'react-hook-form';

return { values, errors: {} as FieldErrors<any> };
return { values, errors: {} };
}
return {
values: {},
errors: toNestError(parsedErrors, options) as FieldErrors<any>,
};
return { values: {}, errors: toNestError(parsedErrors, options) };
};

@@ -1,2 +0,1 @@

/* eslint-disable @typescript-eslint/ban-types */
import type {

@@ -6,13 +5,10 @@ FieldValues,

ResolverResult,
UnpackNestedValue,
} from 'react-hook-form';
import { ValidationState, StrictValidator } from 'typanion';
import { ValidationState, AnyStrictValidator} from 'typanion'
type ValidateOptions = Pick<ValidationState, 'coercions' | 'coercion'>;
type ValidateOptions = Pick<ValidationState, 'coercions' | 'coercion'>
type RHFResolver<
TFieldValues extends FieldValues,
TInput = unknown,
TContext extends Object = object,
> = (
values: TInput,
type RHFResolver = <TFieldValues extends FieldValues, TContext>(
values: UnpackNestedValue<TFieldValues>,
context: TContext | undefined,

@@ -22,9 +18,5 @@ options: ResolverOptions<TFieldValues>,

export type Resolver = <
TInput extends FieldValues = FieldValues,
TFieldValues extends TInput = TInput,
TContext extends object = object,
>(
validator: StrictValidator<TInput, TFieldValues>,
export type Resolver = <UnknownValidator extends AnyStrictValidator>(
validator: UnknownValidator,
validatorOptions?: ValidateOptions,
) => RHFResolver<TFieldValues, TInput, TContext>;
)=> RHFResolver
import {
FieldValues,
ResolverOptions,

@@ -10,7 +11,7 @@ ResolverResult,

export type Resolver = <TFieldValues, TContext>(
export type Resolver = (
schema: ICreateResult,
schemaOptions?: never,
factoryOptions?: { mode?: 'async' | 'sync' },
) => (
) => <TFieldValues extends FieldValues, TContext>(
values: UnpackNestedValue<TFieldValues>,

@@ -17,0 +18,0 @@ context: TContext | undefined,

@@ -1,8 +0,8 @@

import { ResolverOptions, ResolverResult } from 'react-hook-form';
import { FieldValues, ResolverOptions, ResolverResult, UnpackNestedValue } from 'react-hook-form';
import * as Yup from 'yup';
import type Lazy from 'yup/lib/Lazy';
declare type Options<T extends Yup.AnyObjectSchema | Lazy<any>> = Parameters<T['validate']>[1];
export declare type Resolver = <T extends Yup.AnyObjectSchema | Lazy<any>, TContext extends object = object>(schema: T, schemaOptions?: Options<T>, factoryOptions?: {
export declare type Resolver = <T extends Yup.AnyObjectSchema | Lazy<any>>(schema: T, schemaOptions?: Options<T>, factoryOptions?: {
mode?: 'async' | 'sync';
}) => (values: unknown, context: TContext | undefined, options: ResolverOptions<Yup.InferType<T>>) => Promise<ResolverResult<Yup.InferType<T>>>;
}) => <TFieldValues extends FieldValues, TContext>(values: UnpackNestedValue<TFieldValues>, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<ResolverResult<TFieldValues>>;
export {};

@@ -1,3 +0,7 @@

/* eslint-disable @typescript-eslint/ban-types */
import { ResolverOptions, ResolverResult } from 'react-hook-form';
import {
FieldValues,
ResolverOptions,
ResolverResult,
UnpackNestedValue,
} from 'react-hook-form';
import * as Yup from 'yup';

@@ -10,13 +14,10 @@ import type Lazy from 'yup/lib/Lazy';

export type Resolver = <
T extends Yup.AnyObjectSchema | Lazy<any>,
TContext extends object = object,
>(
export type Resolver = <T extends Yup.AnyObjectSchema | Lazy<any>>(
schema: T,
schemaOptions?: Options<T>,
factoryOptions?: { mode?: 'async' | 'sync' },
) => (
values: unknown,
) => <TFieldValues extends FieldValues, TContext>(
values: UnpackNestedValue<TFieldValues>,
context: TContext | undefined,
options: ResolverOptions<Yup.InferType<T>>,
) => Promise<ResolverResult<Yup.InferType<T>>>;
options: ResolverOptions<TFieldValues>,
) => Promise<ResolverResult<TFieldValues>>;

@@ -1,2 +0,2 @@

import Yup, { ValidationError } from 'yup';
import Yup from 'yup';
import { toNestError, validateFieldsNatively } from '@hookform/resolvers';

@@ -62,3 +62,3 @@ import { appendErrors, FieldError } from 'react-hook-form';

};
} catch (e) {
} catch (e: any) {
return {

@@ -68,3 +68,3 @@ values: {},

parseErrorSchema(
e as ValidationError,
e,
!options.shouldUseNativeValidation &&

@@ -71,0 +71,0 @@ options.criteriaMode === 'all',

@@ -1,5 +0,5 @@

import { ResolverResult, ResolverOptions, FieldValues } from 'react-hook-form';
import { FieldValues, ResolverResult, UnpackNestedValue, ResolverOptions } from 'react-hook-form';
import { z } from 'zod';
export declare type Resolver = <TFieldValues extends FieldValues, TContext extends object = object>(schema: z.Schema<TFieldValues, any>, schemaOptions?: Partial<z.ParseParamsNoData>, factoryOptions?: {
export declare type Resolver = <T extends z.Schema<any, any>>(schema: T, schemaOptions?: Partial<z.ParseParamsNoData>, factoryOptions?: {
mode?: 'async' | 'sync';
}) => (values: unknown, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<ResolverResult<TFieldValues>>;
}) => <TFieldValues extends FieldValues, TContext>(values: UnpackNestedValue<TFieldValues>, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<ResolverResult<TFieldValues>>;

@@ -64,3 +64,3 @@ import { zodResolver } from '..';

it.only('should return all the errors from zodResolver when validation fails with `validateAllFieldCriteria` set to true and `mode: sync`', async () => {
it('should return all the errors from zodResolver when validation fails with `validateAllFieldCriteria` set to true and `mode: sync`', async () => {
const result = await zodResolver(schema, undefined, { mode: 'sync' })(

@@ -67,0 +67,0 @@ invalidData,

@@ -1,16 +0,17 @@

/* eslint-disable @typescript-eslint/ban-types */
import { ResolverResult, ResolverOptions, FieldValues } from 'react-hook-form';
import {
FieldValues,
ResolverResult,
UnpackNestedValue,
ResolverOptions,
} from 'react-hook-form';
import { z } from 'zod';
export type Resolver = <
TFieldValues extends FieldValues,
TContext extends object = object,
>(
schema: z.Schema<TFieldValues, any>,
export type Resolver = <T extends z.Schema<any, any>>(
schema: T,
schemaOptions?: Partial<z.ParseParamsNoData>,
factoryOptions?: { mode?: 'async' | 'sync' },
) => (
values: unknown,
) => <TFieldValues extends FieldValues, TContext>(
values: UnpackNestedValue<TFieldValues>,
context: TContext | undefined,
options: ResolverOptions<TFieldValues>,
) => Promise<ResolverResult<TFieldValues>>;
import { appendErrors, FieldError, FieldErrors } from 'react-hook-form';
import { z, ZodError } from 'zod';
import { z } from 'zod';
import { toNestError, validateFieldsNatively } from '@hookform/resolvers';

@@ -67,13 +67,13 @@ import type { Resolver } from './types';

return {
errors: {} as FieldErrors<any>,
errors: {} as FieldErrors,
values: data,
};
} catch (error) {
} catch (error: any) {
return {
values: {},
errors: (error as ZodError).isEmpty
? ({} as FieldErrors<any>)
: (toNestError(
errors: error.isEmpty
? {}
: toNestError(
parseErrorSchema(
(error as ZodError).errors,
error.errors,
!options.shouldUseNativeValidation &&

@@ -83,5 +83,5 @@ options.criteriaMode === 'all',

options,
) as FieldErrors<any>),
),
};
}
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc