@hookform/resolvers 5.7.1 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hookform/resolvers",
3
3
  "amdName": "hookformResolvers",
4
- "version": "5.7.1",
4
+ "version": "5.9.0",
5
5
  "description": "React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts, Nope, computed-types, TypeBox, arktype, Typanion, Effect-TS and VineJS",
6
6
  "main": "dist/resolvers.js",
7
7
  "module": "dist/resolvers.module.js",
@@ -216,7 +216,7 @@
216
216
  "build:joi": "microbundle --cwd joi --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
217
217
  "build:superstruct": "microbundle --cwd superstruct --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
218
218
  "build:io-ts": "microbundle --cwd io-ts --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,fp-ts/Either=Either,fp-ts/function=_function,fp-ts/Option=Option,fp-ts/ReadonlyArray=ReadonlyArray,fp-ts/Semigroup=Semigroup,fp-ts/ReadonlyRecord=ReadonlyRecord",
219
- "build:vest": "microbundle --cwd vest --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,vest/promisify=promisify",
219
+ "build:vest": "microbundle --cwd vest --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
220
220
  "build:class-validator": "microbundle --cwd class-validator --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
221
221
  "build:nope": "microbundle --cwd nope --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
222
222
  "build:computed-types": "microbundle --cwd computed-types --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
@@ -305,7 +305,7 @@
305
305
  "fp-ts": "^2.16.11",
306
306
  "io-ts": "^2.2.22",
307
307
  "io-ts-types": "^0.5.19",
308
- "joi": "^17.13.4",
308
+ "joi": "^18.2.3",
309
309
  "jsdom": "^26.1.0",
310
310
  "lefthook": "^1.13.6",
311
311
  "microbundle": "^0.15.1",
@@ -321,7 +321,7 @@
321
321
  "typanion": "^3.14.0",
322
322
  "typescript": "^6.0.3",
323
323
  "valibot": "1.0.0-beta.12",
324
- "vest": "^5.4.6",
324
+ "vest": "^6.3.2",
325
325
  "vite": "^6.4.3",
326
326
  "vite-tsconfig-paths": "^5.1.4",
327
327
  "vitest": "^3.2.7",
@@ -345,13 +345,13 @@
345
345
  "fluentvalidation-ts": "^3.0.0",
346
346
  "fp-ts": "^2.7.0",
347
347
  "io-ts": "^2.0.0",
348
- "joi": "^17.0.0",
348
+ "joi": "^17.0.0 || ^18.0.0",
349
349
  "nope-validator": ">=0.12.0",
350
350
  "react-hook-form": "^7.55.0",
351
351
  "superstruct": ">=0.12.0",
352
352
  "typanion": "^3.3.2",
353
353
  "valibot": ">=0.31.0 || ^1.0.0-beta.4 || ^1.0.0-rc",
354
- "vest": ">=3.0.0",
354
+ "vest": ">=6.0.0",
355
355
  "yup": "^1.0.0",
356
356
  "zod": "^3.25.0 || ^4.0.0"
357
357
  },
@@ -1,6 +1,6 @@
1
1
  import { FieldName, FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
2
- import * as Vest from 'vest';
3
- export type ICreateResult<TValues extends FieldValues = FieldValues, TContext = any> = ReturnType<typeof Vest.create<any, any, (values: TValues, names?: FieldName<TValues>[], context?: TContext) => void>>;
2
+ import type { Suite } from 'vest';
3
+ export type ICreateResult<TValues extends FieldValues = FieldValues, TContext = any> = Suite<any, any, (values: TValues, names?: FieldName<TValues>[], context?: TContext) => void>;
4
4
  export type Resolver = <TValues extends FieldValues, TContext>(schema: ICreateResult<TValues, TContext>, schemaOptions?: never, factoryOptions?: {
5
5
  mode?: 'async' | 'sync';
6
6
  rawValues?: boolean;
package/vest/dist/vest.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=require("@hookform/resolvers");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=/*#__PURE__*/r(require("vest/promisify")),o=function(e,r){var t=Object.create(null);for(var o in e)t[o]||(t[o]={message:e[o][0],type:""}),r&&(t[o].types=e[o].reduce(function(e,r,t){return(e[t]=r)&&e},{}));return t};exports.vestResolver=function(r,s,n){return void 0===n&&(n={}),function(s,a,i){try{var u=function(r){return r.hasErrors()?{values:{},errors:e.toNestErrors(o(r.getErrors(),!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)}:(i.shouldUseNativeValidation&&e.validateFieldsNatively({},i),{values:s,errors:{}})};return Promise.resolve("sync"===n.mode?u(r(s,i.names,a)):Promise.resolve(t.default(r)(s,i.names,a)).then(u))}catch(e){return Promise.reject(e)}}};
1
+ var r=require("@hookform/resolvers"),e=function(r,e){var t=Object.create(null);for(var o in r)t[o]||(t[o]={message:r[o][0],type:""}),e&&(t[o].types=r[o].reduce(function(r,e,t){return(r[t]=e)&&r},{}));return t};exports.vestResolver=function(t,o,s){return void 0===s&&(s={}),function(o,n,a){try{var i=function(t){return t.hasErrors()?{values:{},errors:r.toNestErrors(e(t.getErrors(),!a.shouldUseNativeValidation&&"all"===a.criteriaMode),a)}:(a.shouldUseNativeValidation&&r.validateFieldsNatively({},a),{values:o,errors:{}})};return Promise.resolve("sync"===s.mode?i(t.run(o,a.names,n)):Promise.resolve(t.run(o,a.names,n)).then(i))}catch(r){return Promise.reject(r)}}};
2
2
  //# sourceMappingURL=vest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vest.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport promisify from 'vest/promisify';\nimport type { Resolver, VestErrors } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record<string, FieldError> = Object.create(null);\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce<Record<number, string>>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\n/**\n * Creates a resolver for react-hook-form using Vest validation\n * @param {Function} schema - The Vest validation schema\n * @param {Object} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = vest.create((data) => {\n * if (!data.name) {\n * return 'Name is required';\n * }\n * });\n *\n * useForm({\n * resolver: vestResolver(schema)\n * });\n */\nexport const vestResolver: Resolver =\n (schema, _, resolverOptions = {}) =>\n async (values, context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema(values, options.names, context)\n : await promisify(schema)(values, options.names, context);\n\n if (result.hasErrors()) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n result.getErrors(),\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","Object","create","path","message","type","types","reduce","acc","index","schema","_","resolverOptions","values","context","options","_temp2","result","hasErrors","toNestErrors","getErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","Promise","resolve","mode","names","promisify","then","e","reject"],"mappings":"6JAKMA,EAAmB,SACvBC,EACAC,GAGA,IAAMC,EAAqCC,OAAOC,OAAO,MACzD,IAAK,IAAMC,KAAQL,EACZE,EAAOG,KACVH,EAAOG,GAAQ,CAAEC,QAASN,EAAUK,GAAM,GAAIE,KAAM,KAGlDN,IACFC,EAAOG,GAAMG,MAAQR,EAAUK,GAAMI,OACnC,SAACC,EAAKJ,EAASK,GAAK,OAAMD,EAAIC,GAASL,IAAYI,CAAG,EACtD,CAAE,IAIR,OAAOR,CACT,uBAqBE,SAACU,EAAQC,EAAGC,GACLC,gBADKD,IAAAA,EAAkB,CAAA,GACvBC,SAAAA,EAAQC,EAASC,GAAW,IAAA,IAAAC,EAAA,SAC3BC,GAKN,OAAIA,EAAOC,YACF,CACLL,OAAQ,CAAA,EACRb,OAAQmB,EAAYA,aAClBtB,EACEoB,EAAOG,aACNL,EAAQM,2BACkB,QAAzBN,EAAQO,cAEZP,KAKNA,EAAQM,2BAA6BE,EAAAA,uBAAuB,CAAA,EAAIR,GAEzD,CAAEF,OAAAA,EAAQb,OAAQ,IAAK,EApBGwB,OAAAA,QAAAC,QAAN,SAAzBb,EAAgBc,KAAeV,EAC3BN,EAAOG,EAAQE,EAAQY,MAAOb,IAAQU,QAAAC,QAChCG,EAAAA,QAAUlB,EAAVkB,CAAkBf,EAAQE,EAAQY,MAAOb,IAAQe,KAAAb,GAmB/D,CAAC,MAAAc,GAAAN,OAAAA,QAAAO,OAAAD,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"vest.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport type { Resolver, VestErrors } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record<string, FieldError> = Object.create(null);\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce<Record<number, string>>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\n/**\n * Creates a resolver for react-hook-form using Vest validation\n * @param {Function} schema - The Vest validation schema\n * @param {Object} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = vest.create((data) => {\n * if (!data.name) {\n * return 'Name is required';\n * }\n * });\n *\n * useForm({\n * resolver: vestResolver(schema)\n * });\n */\nexport const vestResolver: Resolver =\n (schema, _, resolverOptions = {}) =>\n async (values, context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema.run(values, options.names, context)\n : await schema.run(values, options.names, context);\n\n if (result.hasErrors()) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n result.getErrors(),\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","Object","create","path","message","type","types","reduce","acc","index","schema","_","resolverOptions","values","context","options","_temp2","result","hasErrors","toNestErrors","getErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","Promise","resolve","mode","run","names","then","e","reject"],"mappings":"qCAIMA,EAAmB,SACvBC,EACAC,GAGA,IAAMC,EAAqCC,OAAOC,OAAO,MACzD,IAAK,IAAMC,KAAQL,EACZE,EAAOG,KACVH,EAAOG,GAAQ,CAAEC,QAASN,EAAUK,GAAM,GAAIE,KAAM,KAGlDN,IACFC,EAAOG,GAAMG,MAAQR,EAAUK,GAAMI,OACnC,SAACC,EAAKJ,EAASK,GAAK,OAAMD,EAAIC,GAASL,IAAYI,CAAG,EACtD,CAAA,IAIN,OAAOR,CACT,uBAqBE,SAACU,EAAQC,EAAGC,GAAoB,YAAL,IAAfA,IAAAA,EAAkB,CAAE,GAAA,SACzBC,EAAQC,EAASC,GAAO,IAAIC,IAAAA,EAAAA,SAC3BC,GAKN,OAAIA,EAAOC,YACF,CACLL,OAAQ,CAAE,EACVb,OAAQmB,eACNtB,EACEoB,EAAOG,aACNL,EAAQM,2BACkB,QAAzBN,EAAQO,cAEZP,KAKNA,EAAQM,2BAA6BE,EAAsBA,uBAAC,CAAE,EAAER,GAEzD,CAAEF,OAAAA,EAAQb,OAAQ,IAAK,EApBG,OAAAwB,QAAAC,QAAN,SAAzBb,EAAgBc,KAAeV,EAC3BN,EAAOiB,IAAId,EAAQE,EAAQa,MAAOd,IAAQU,QAAAC,QACpCf,EAAOiB,IAAId,EAAQE,EAAQa,MAAOd,IAAQe,KAAAb,GAmBxD,CAAC,MAAAc,GAAAN,OAAAA,QAAAO,OAAAD,EAAA,CAAA,CAAA"}
@@ -1,2 +1,2 @@
1
- import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import o from"vest/promisify";var t=function(r,e){var o=Object.create(null);for(var t in r)o[t]||(o[t]={message:r[t][0],type:""}),e&&(o[t].types=r[t].reduce(function(r,e,o){return(r[o]=e)&&r},{}));return o},s=function(s,n,i){return void 0===i&&(i={}),function(n,a,u){try{var c=function(o){return o.hasErrors()?{values:{},errors:r(t(o.getErrors(),!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)}:(u.shouldUseNativeValidation&&e({},u),{values:n,errors:{}})};return Promise.resolve("sync"===i.mode?c(s(n,u.names,a)):Promise.resolve(o(s)(n,u.names,a)).then(c))}catch(r){return Promise.reject(r)}}};export{s as vestResolver};
1
+ import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";var o=function(r,e){var o=Object.create(null);for(var t in r)o[t]||(o[t]={message:r[t][0],type:""}),e&&(o[t].types=r[t].reduce(function(r,e,o){return(r[o]=e)&&r},{}));return o},t=function(t,n,s){return void 0===s&&(s={}),function(n,a,i){try{var u=function(t){return t.hasErrors()?{values:{},errors:r(o(t.getErrors(),!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)}:(i.shouldUseNativeValidation&&e({},i),{values:n,errors:{}})};return Promise.resolve("sync"===s.mode?u(t.run(n,i.names,a)):Promise.resolve(t.run(n,i.names,a)).then(u))}catch(r){return Promise.reject(r)}}};export{t as vestResolver};
2
2
  //# sourceMappingURL=vest.module.js.map
@@ -1,2 +1,2 @@
1
- import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import s from"vest/promisify";const o=(r,e)=>{const s=Object.create(null);for(const o in r)s[o]||(s[o]={message:r[o][0],type:""}),e&&(s[o].types=r[o].reduce((r,e,s)=>(r[s]=e)&&r,{}));return s},t=(t,a,i={})=>async(a,n,l)=>{const c="sync"===i.mode?t(a,l.names,n):await s(t)(a,l.names,n);return c.hasErrors()?{values:{},errors:r(o(c.getErrors(),!l.shouldUseNativeValidation&&"all"===l.criteriaMode),l)}:(l.shouldUseNativeValidation&&e({},l),{values:a,errors:{}})};export{t as vestResolver};
1
+ import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";const s=(r,e)=>{const s=Object.create(null);for(const o in r)s[o]||(s[o]={message:r[o][0],type:""}),e&&(s[o].types=r[o].reduce((r,e,s)=>(r[s]=e)&&r,{}));return s},o=(o,t,a={})=>async(t,n,i)=>{const l="sync"===a.mode?o.run(t,i.names,n):await o.run(t,i.names,n);return l.hasErrors()?{values:{},errors:r(s(l.getErrors(),!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)}:(i.shouldUseNativeValidation&&e({},i),{values:t,errors:{}})};export{o as vestResolver};
2
2
  //# sourceMappingURL=vest.modern.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"vest.modern.mjs","sources":["../src/vest.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport promisify from 'vest/promisify';\nimport type { Resolver, VestErrors } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record<string, FieldError> = Object.create(null);\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce<Record<number, string>>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\n/**\n * Creates a resolver for react-hook-form using Vest validation\n * @param {Function} schema - The Vest validation schema\n * @param {Object} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = vest.create((data) => {\n * if (!data.name) {\n * return 'Name is required';\n * }\n * });\n *\n * useForm({\n * resolver: vestResolver(schema)\n * });\n */\nexport const vestResolver: Resolver =\n (schema, _, resolverOptions = {}) =>\n async (values, context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema(values, options.names, context)\n : await promisify(schema)(values, options.names, context);\n\n if (result.hasErrors()) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n result.getErrors(),\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","Object","create","path","message","type","types","reduce","acc","index","vestResolver","schema","_","resolverOptions","async","values","context","options","result","mode","names","promisify","hasErrors","toNestErrors","getErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively"],"mappings":"6GAKA,MAAMA,EAAmBA,CACvBC,EACAC,KAGA,MAAMC,EAAqCC,OAAOC,OAAO,MACzD,IAAK,MAAMC,KAAQL,EACZE,EAAOG,KACVH,EAAOG,GAAQ,CAAEC,QAASN,EAAUK,GAAM,GAAIE,KAAM,KAGlDN,IACFC,EAAOG,GAAMG,MAAQR,EAAUK,GAAMI,OACnC,CAACC,EAAKJ,EAASK,KAAWD,EAAIC,GAASL,IAAYI,EACnD,CAAA,IAIN,OAAOR,CAAM,EAqBFU,EACXA,CAACC,EAAQC,EAAGC,EAAkB,KAC9BC,MAAOC,EAAQC,EAASC,KACtB,MAAMC,EACqB,SAAzBL,EAAgBM,KACZR,EAAOI,EAAQE,EAAQG,MAAOJ,SACxBK,EAAUV,EAAVU,CAAkBN,EAAQE,EAAQG,MAAOJ,GAErD,OAAIE,EAAOI,YACF,CACLP,OAAQ,CAAE,EACVf,OAAQuB,EACN1B,EACEqB,EAAOM,aACNP,EAAQQ,2BACkB,QAAzBR,EAAQS,cAEZT,KAKNA,EAAQQ,2BAA6BE,EAAuB,CAAA,EAAIV,GAEzD,CAAEF,SAAQf,OAAQ,IAAI"}
1
+ {"version":3,"file":"vest.modern.mjs","sources":["../src/vest.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport type { Resolver, VestErrors } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record<string, FieldError> = Object.create(null);\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce<Record<number, string>>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\n/**\n * Creates a resolver for react-hook-form using Vest validation\n * @param {Function} schema - The Vest validation schema\n * @param {Object} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = vest.create((data) => {\n * if (!data.name) {\n * return 'Name is required';\n * }\n * });\n *\n * useForm({\n * resolver: vestResolver(schema)\n * });\n */\nexport const vestResolver: Resolver =\n (schema, _, resolverOptions = {}) =>\n async (values, context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema.run(values, options.names, context)\n : await schema.run(values, options.names, context);\n\n if (result.hasErrors()) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n result.getErrors(),\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","Object","create","path","message","type","types","reduce","acc","index","vestResolver","schema","_","resolverOptions","async","values","context","options","result","mode","run","names","hasErrors","toNestErrors","getErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively"],"mappings":"+EAIA,MAAMA,EAAmBA,CACvBC,EACAC,KAGA,MAAMC,EAAqCC,OAAOC,OAAO,MACzD,IAAK,MAAMC,KAAQL,EACZE,EAAOG,KACVH,EAAOG,GAAQ,CAAEC,QAASN,EAAUK,GAAM,GAAIE,KAAM,KAGlDN,IACFC,EAAOG,GAAMG,MAAQR,EAAUK,GAAMI,OACnC,CAACC,EAAKJ,EAASK,KAAWD,EAAIC,GAASL,IAAYI,EACnD,CAAE,IAIR,OAAOR,CAAM,EAqBFU,EACXA,CAACC,EAAQC,EAAGC,EAAkB,CAAA,IAC9BC,MAAOC,EAAQC,EAASC,KACtB,MAAMC,EACqB,SAAzBL,EAAgBM,KACZR,EAAOS,IAAIL,EAAQE,EAAQI,MAAOL,SAC5BL,EAAOS,IAAIL,EAAQE,EAAQI,MAAOL,GAE9C,OAAIE,EAAOI,YACF,CACLP,OAAQ,CAAE,EACVf,OAAQuB,EACN1B,EACEqB,EAAOM,aACNP,EAAQQ,2BACkB,QAAzBR,EAAQS,cAEZT,KAKNA,EAAQQ,2BAA6BE,EAAuB,CAAA,EAAIV,GAEzD,CAAEF,SAAQf,OAAQ,IAAI"}
@@ -1,2 +1,2 @@
1
- import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import o from"vest/promisify";var t=function(r,e){var o=Object.create(null);for(var t in r)o[t]||(o[t]={message:r[t][0],type:""}),e&&(o[t].types=r[t].reduce(function(r,e,o){return(r[o]=e)&&r},{}));return o},s=function(s,n,i){return void 0===i&&(i={}),function(n,a,u){try{var c=function(o){return o.hasErrors()?{values:{},errors:r(t(o.getErrors(),!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)}:(u.shouldUseNativeValidation&&e({},u),{values:n,errors:{}})};return Promise.resolve("sync"===i.mode?c(s(n,u.names,a)):Promise.resolve(o(s)(n,u.names,a)).then(c))}catch(r){return Promise.reject(r)}}};export{s as vestResolver};
1
+ import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";var o=function(r,e){var o=Object.create(null);for(var t in r)o[t]||(o[t]={message:r[t][0],type:""}),e&&(o[t].types=r[t].reduce(function(r,e,o){return(r[o]=e)&&r},{}));return o},t=function(t,n,s){return void 0===s&&(s={}),function(n,a,i){try{var u=function(t){return t.hasErrors()?{values:{},errors:r(o(t.getErrors(),!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)}:(i.shouldUseNativeValidation&&e({},i),{values:n,errors:{}})};return Promise.resolve("sync"===s.mode?u(t.run(n,i.names,a)):Promise.resolve(t.run(n,i.names,a)).then(u))}catch(r){return Promise.reject(r)}}};export{t as vestResolver};
2
2
  //# sourceMappingURL=vest.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vest.module.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport promisify from 'vest/promisify';\nimport type { Resolver, VestErrors } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record<string, FieldError> = Object.create(null);\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce<Record<number, string>>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\n/**\n * Creates a resolver for react-hook-form using Vest validation\n * @param {Function} schema - The Vest validation schema\n * @param {Object} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = vest.create((data) => {\n * if (!data.name) {\n * return 'Name is required';\n * }\n * });\n *\n * useForm({\n * resolver: vestResolver(schema)\n * });\n */\nexport const vestResolver: Resolver =\n (schema, _, resolverOptions = {}) =>\n async (values, context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema(values, options.names, context)\n : await promisify(schema)(values, options.names, context);\n\n if (result.hasErrors()) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n result.getErrors(),\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","Object","create","path","message","type","types","reduce","acc","index","vestResolver","schema","_","resolverOptions","values","context","options","_temp2","result","hasErrors","toNestErrors","getErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","Promise","resolve","mode","names","promisify","then","e","reject"],"mappings":"6GAKA,IAAMA,EAAmB,SACvBC,EACAC,GAGA,IAAMC,EAAqCC,OAAOC,OAAO,MACzD,IAAK,IAAMC,KAAQL,EACZE,EAAOG,KACVH,EAAOG,GAAQ,CAAEC,QAASN,EAAUK,GAAM,GAAIE,KAAM,KAGlDN,IACFC,EAAOG,GAAMG,MAAQR,EAAUK,GAAMI,OACnC,SAACC,EAAKJ,EAASK,GAAK,OAAMD,EAAIC,GAASL,IAAYI,CAAG,EACtD,CAAE,IAIR,OAAOR,CACT,EAoBaU,EACX,SAACC,EAAQC,EAAGC,GACLC,gBADKD,IAAAA,EAAkB,CAAA,GACvBC,SAAAA,EAAQC,EAASC,GAAW,IAAA,IAAAC,EAAA,SAC3BC,GAKN,OAAIA,EAAOC,YACF,CACLL,OAAQ,CAAA,EACRd,OAAQoB,EACNvB,EACEqB,EAAOG,aACNL,EAAQM,2BACkB,QAAzBN,EAAQO,cAEZP,KAKNA,EAAQM,2BAA6BE,EAAuB,CAAA,EAAIR,GAEzD,CAAEF,OAAAA,EAAQd,OAAQ,IAAK,EApBGyB,OAAAA,QAAAC,QAAN,SAAzBb,EAAgBc,KAAeV,EAC3BN,EAAOG,EAAQE,EAAQY,MAAOb,IAAQU,QAAAC,QAChCG,EAAUlB,EAAVkB,CAAkBf,EAAQE,EAAQY,MAAOb,IAAQe,KAAAb,GAmB/D,CAAC,MAAAc,GAAAN,OAAAA,QAAAO,OAAAD,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"vest.module.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport type { Resolver, VestErrors } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record<string, FieldError> = Object.create(null);\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce<Record<number, string>>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\n/**\n * Creates a resolver for react-hook-form using Vest validation\n * @param {Function} schema - The Vest validation schema\n * @param {Object} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = vest.create((data) => {\n * if (!data.name) {\n * return 'Name is required';\n * }\n * });\n *\n * useForm({\n * resolver: vestResolver(schema)\n * });\n */\nexport const vestResolver: Resolver =\n (schema, _, resolverOptions = {}) =>\n async (values, context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema.run(values, options.names, context)\n : await schema.run(values, options.names, context);\n\n if (result.hasErrors()) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n result.getErrors(),\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","Object","create","path","message","type","types","reduce","acc","index","vestResolver","schema","_","resolverOptions","values","context","options","_temp2","result","hasErrors","toNestErrors","getErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","Promise","resolve","mode","run","names","then","e","reject"],"mappings":"+EAIA,IAAMA,EAAmB,SACvBC,EACAC,GAGA,IAAMC,EAAqCC,OAAOC,OAAO,MACzD,IAAK,IAAMC,KAAQL,EACZE,EAAOG,KACVH,EAAOG,GAAQ,CAAEC,QAASN,EAAUK,GAAM,GAAIE,KAAM,KAGlDN,IACFC,EAAOG,GAAMG,MAAQR,EAAUK,GAAMI,OACnC,SAACC,EAAKJ,EAASK,GAAK,OAAMD,EAAIC,GAASL,IAAYI,CAAG,EACtD,CAAA,IAIN,OAAOR,CACT,EAoBaU,EACX,SAACC,EAAQC,EAAGC,GAAoB,YAAL,IAAfA,IAAAA,EAAkB,CAAE,GAAA,SACzBC,EAAQC,EAASC,GAAO,IAAIC,IAAAA,EAAAA,SAC3BC,GAKN,OAAIA,EAAOC,YACF,CACLL,OAAQ,CAAE,EACVd,OAAQoB,EACNvB,EACEqB,EAAOG,aACNL,EAAQM,2BACkB,QAAzBN,EAAQO,cAEZP,KAKNA,EAAQM,2BAA6BE,EAAuB,CAAE,EAAER,GAEzD,CAAEF,OAAAA,EAAQd,OAAQ,IAAK,EApBG,OAAAyB,QAAAC,QAAN,SAAzBb,EAAgBc,KAAeV,EAC3BN,EAAOiB,IAAId,EAAQE,EAAQa,MAAOd,IAAQU,QAAAC,QACpCf,EAAOiB,IAAId,EAAQE,EAAQa,MAAOd,IAAQe,KAAAb,GAmBxD,CAAC,MAAAc,GAAAN,OAAAA,QAAAO,OAAAD,EAAA,CAAA,CAAA"}
@@ -1,2 +1,2 @@
1
- !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("vest/promisify")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","vest/promisify"],r):r((e||self).hookformResolversVest={},e.hookformResolvers,e.promisify)}(this,function(e,r,o){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=/*#__PURE__*/t(o),i=function(e,r){var o=Object.create(null);for(var t in e)o[t]||(o[t]={message:e[t][0],type:""}),r&&(o[t].types=e[t].reduce(function(e,r,o){return(e[o]=r)&&e},{}));return o};e.vestResolver=function(e,o,t){return void 0===t&&(t={}),function(o,n,f){try{var u=function(e){return e.hasErrors()?{values:{},errors:r.toNestErrors(i(e.getErrors(),!f.shouldUseNativeValidation&&"all"===f.criteriaMode),f)}:(f.shouldUseNativeValidation&&r.validateFieldsNatively({},f),{values:o,errors:{}})};return Promise.resolve("sync"===t.mode?u(e(o,f.names,n)):Promise.resolve(s.default(e)(o,f.names,n)).then(u))}catch(e){return Promise.reject(e)}}}});
1
+ !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers"],r):r((e||self).hookformResolversVest={},e.hookformResolvers)}(this,function(e,r){var o=function(e,r){var o=Object.create(null);for(var s in e)o[s]||(o[s]={message:e[s][0],type:""}),r&&(o[s].types=e[s].reduce(function(e,r,o){return(e[o]=r)&&e},{}));return o};e.vestResolver=function(e,s,t){return void 0===t&&(t={}),function(s,n,i){try{var a=function(e){return e.hasErrors()?{values:{},errors:r.toNestErrors(o(e.getErrors(),!i.shouldUseNativeValidation&&"all"===i.criteriaMode),i)}:(i.shouldUseNativeValidation&&r.validateFieldsNatively({},i),{values:s,errors:{}})};return Promise.resolve("sync"===t.mode?a(e.run(s,i.names,n)):Promise.resolve(e.run(s,i.names,n)).then(a))}catch(e){return Promise.reject(e)}}}});
2
2
  //# sourceMappingURL=vest.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vest.umd.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport promisify from 'vest/promisify';\nimport type { Resolver, VestErrors } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record<string, FieldError> = Object.create(null);\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce<Record<number, string>>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\n/**\n * Creates a resolver for react-hook-form using Vest validation\n * @param {Function} schema - The Vest validation schema\n * @param {Object} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = vest.create((data) => {\n * if (!data.name) {\n * return 'Name is required';\n * }\n * });\n *\n * useForm({\n * resolver: vestResolver(schema)\n * });\n */\nexport const vestResolver: Resolver =\n (schema, _, resolverOptions = {}) =>\n async (values, context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema(values, options.names, context)\n : await promisify(schema)(values, options.names, context);\n\n if (result.hasErrors()) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n result.getErrors(),\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","Object","create","path","message","type","types","reduce","acc","index","schema","_","resolverOptions","values","context","options","_temp2","result","hasErrors","toNestErrors","getErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","Promise","resolve","mode","names","promisify","then","e","reject"],"mappings":"mdAKMA,EAAmB,SACvBC,EACAC,GAGA,IAAMC,EAAqCC,OAAOC,OAAO,MACzD,IAAK,IAAMC,KAAQL,EACZE,EAAOG,KACVH,EAAOG,GAAQ,CAAEC,QAASN,EAAUK,GAAM,GAAIE,KAAM,KAGlDN,IACFC,EAAOG,GAAMG,MAAQR,EAAUK,GAAMI,OACnC,SAACC,EAAKJ,EAASK,GAAK,OAAMD,EAAIC,GAASL,IAAYI,CAAG,EACtD,CAAE,IAIR,OAAOR,CACT,iBAqBE,SAACU,EAAQC,EAAGC,GACLC,gBADKD,IAAAA,EAAkB,CAAA,GACvBC,SAAAA,EAAQC,EAASC,GAAW,IAAA,IAAAC,EAAA,SAC3BC,GAKN,OAAIA,EAAOC,YACF,CACLL,OAAQ,CAAA,EACRb,OAAQmB,EAAYA,aAClBtB,EACEoB,EAAOG,aACNL,EAAQM,2BACkB,QAAzBN,EAAQO,cAEZP,KAKNA,EAAQM,2BAA6BE,EAAAA,uBAAuB,CAAA,EAAIR,GAEzD,CAAEF,OAAAA,EAAQb,OAAQ,IAAK,EApBGwB,OAAAA,QAAAC,QAAN,SAAzBb,EAAgBc,KAAeV,EAC3BN,EAAOG,EAAQE,EAAQY,MAAOb,IAAQU,QAAAC,QAChCG,EAAAA,QAAUlB,EAAVkB,CAAkBf,EAAQE,EAAQY,MAAOb,IAAQe,KAAAb,GAmB/D,CAAC,MAAAc,GAAAN,OAAAA,QAAAO,OAAAD,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"vest.umd.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport type { Resolver, VestErrors } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n // See the matching comment in the zod resolver's `parseZod3Issues`.\n const errors: Record<string, FieldError> = Object.create(null);\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce<Record<number, string>>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\n/**\n * Creates a resolver for react-hook-form using Vest validation\n * @param {Function} schema - The Vest validation schema\n * @param {Object} _ - Unused parameter\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver} A resolver function compatible with react-hook-form\n * @example\n * const schema = vest.create((data) => {\n * if (!data.name) {\n * return 'Name is required';\n * }\n * });\n *\n * useForm({\n * resolver: vestResolver(schema)\n * });\n */\nexport const vestResolver: Resolver =\n (schema, _, resolverOptions = {}) =>\n async (values, context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema.run(values, options.names, context)\n : await schema.run(values, options.names, context);\n\n if (result.hasErrors()) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n result.getErrors(),\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","Object","create","path","message","type","types","reduce","acc","index","schema","_","resolverOptions","values","context","options","_temp2","result","hasErrors","toNestErrors","getErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","Promise","resolve","mode","run","names","then","e","reject"],"mappings":"0TAIA,IAAMA,EAAmB,SACvBC,EACAC,GAGA,IAAMC,EAAqCC,OAAOC,OAAO,MACzD,IAAK,IAAMC,KAAQL,EACZE,EAAOG,KACVH,EAAOG,GAAQ,CAAEC,QAASN,EAAUK,GAAM,GAAIE,KAAM,KAGlDN,IACFC,EAAOG,GAAMG,MAAQR,EAAUK,GAAMI,OACnC,SAACC,EAAKJ,EAASK,GAAK,OAAMD,EAAIC,GAASL,IAAYI,CAAG,EACtD,CAAA,IAIN,OAAOR,CACT,iBAqBE,SAACU,EAAQC,EAAGC,GAAoB,YAAL,IAAfA,IAAAA,EAAkB,CAAE,GAAA,SACzBC,EAAQC,EAASC,GAAO,IAAIC,IAAAA,EAAAA,SAC3BC,GAKN,OAAIA,EAAOC,YACF,CACLL,OAAQ,CAAE,EACVb,OAAQmB,eACNtB,EACEoB,EAAOG,aACNL,EAAQM,2BACkB,QAAzBN,EAAQO,cAEZP,KAKNA,EAAQM,2BAA6BE,EAAsBA,uBAAC,CAAE,EAAER,GAEzD,CAAEF,OAAAA,EAAQb,OAAQ,IAAK,EApBG,OAAAwB,QAAAC,QAAN,SAAzBb,EAAgBc,KAAeV,EAC3BN,EAAOiB,IAAId,EAAQE,EAAQa,MAAOd,IAAQU,QAAAC,QACpCf,EAAOiB,IAAId,EAAQE,EAAQa,MAAOd,IAAQe,KAAAb,GAmBxD,CAAC,MAAAc,GAAAN,OAAAA,QAAAO,OAAAD,EAAA,CAAA,CAAA"}
@@ -13,7 +13,7 @@ interface FormData {
13
13
  password: string;
14
14
  }
15
15
 
16
- const validationSuite = vest.create('form', (data: FormData) => {
16
+ const validationSuite = vest.create((data: FormData) => {
17
17
  vest.test('username', USERNAME_REQUIRED_MESSAGE, () => {
18
18
  vest.enforce(data.username).isNotEmpty();
19
19
  });
@@ -10,7 +10,7 @@ interface FormData {
10
10
  password: string;
11
11
  }
12
12
 
13
- const validationSuite = vest.create('form', (data: FormData) => {
13
+ const validationSuite = vest.create((data: FormData) => {
14
14
  vest.test('username', 'Username is required', () => {
15
15
  vest.enforce(data.username).isNotEmpty();
16
16
  });
@@ -1,7 +1,7 @@
1
1
  import { Field, InternalFieldName } from 'react-hook-form';
2
2
  import * as vest from 'vest';
3
3
 
4
- export const validationSuite = vest.create('form', (data: any = {}) => {
4
+ export const validationSuite = vest.create((data: any = {}) => {
5
5
  vest.test('username', 'Username is required', () => {
6
6
  vest.enforce(data.username).isNotEmpty();
7
7
  });
@@ -12,10 +12,12 @@ describe('vestResolver special path names', () => {
12
12
  // unreachable through this resolver's public API regardless of this
13
13
  // fix. A fake schema function isolates the resolver's own
14
14
  // path-tracking logic instead.
15
- const schema = () => ({
16
- hasErrors: () => true,
17
- getErrors: () => ({ [name]: [`${name} is required`] }),
18
- });
15
+ const schema = {
16
+ run: () => ({
17
+ hasErrors: () => true,
18
+ getErrors: () => ({ [name]: [`${name} is required`] }),
19
+ }),
20
+ };
19
21
 
20
22
  const result = await vestResolver(schema as any, undefined, {
21
23
  mode: 'sync',
@@ -70,9 +70,9 @@ describe('vestResolver', () => {
70
70
  });
71
71
 
72
72
  it('should call a suite with values, validated field names and a context as arguments', async () => {
73
- const suite = vi.fn(validationSuite) as any as typeof validationSuite;
73
+ const run = vi.spyOn(validationSuite, 'run');
74
74
 
75
- await vestResolver(suite)(
75
+ await vestResolver(validationSuite)(
76
76
  validData,
77
77
  { some: 'context' },
78
78
  {
@@ -82,8 +82,8 @@ describe('vestResolver', () => {
82
82
  },
83
83
  );
84
84
 
85
- expect(suite).toHaveBeenCalledTimes(1);
86
- expect(suite).toHaveBeenCalledWith(validData, ['username'], {
85
+ expect(run).toHaveBeenCalledTimes(1);
86
+ expect(run).toHaveBeenCalledWith(validData, ['username'], {
87
87
  some: 'context',
88
88
  });
89
89
  });
package/vest/src/types.ts CHANGED
@@ -4,17 +4,15 @@ import {
4
4
  ResolverOptions,
5
5
  ResolverResult,
6
6
  } from 'react-hook-form';
7
- import * as Vest from 'vest';
7
+ import type { Suite } from 'vest';
8
8
 
9
9
  export type ICreateResult<
10
10
  TValues extends FieldValues = FieldValues,
11
11
  TContext = any,
12
- > = ReturnType<
13
- typeof Vest.create<
14
- any,
15
- any,
16
- (values: TValues, names?: FieldName<TValues>[], context?: TContext) => void
17
- >
12
+ > = Suite<
13
+ any,
14
+ any,
15
+ (values: TValues, names?: FieldName<TValues>[], context?: TContext) => void
18
16
  >;
19
17
 
20
18
  export type Resolver = <TValues extends FieldValues, TContext>(
package/vest/src/vest.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';
2
2
  import { FieldError } from 'react-hook-form';
3
- import promisify from 'vest/promisify';
4
3
  import type { Resolver, VestErrors } from './types';
5
4
 
6
5
  const parseErrorSchema = (
@@ -47,8 +46,8 @@ export const vestResolver: Resolver =
47
46
  async (values, context, options) => {
48
47
  const result =
49
48
  resolverOptions.mode === 'sync'
50
- ? schema(values, options.names, context)
51
- : await promisify(schema)(values, options.names, context);
49
+ ? schema.run(values, options.names, context)
50
+ : await schema.run(values, options.names, context);
52
51
 
53
52
  if (result.hasErrors()) {
54
53
  return {