@hookform/resolvers 4.0.0 → 4.1.1
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/README.md +35 -2
- package/ajv/dist/ajv.d.ts +20 -0
- package/ajv/dist/ajv.js.map +1 -1
- package/ajv/dist/ajv.modern.mjs.map +1 -1
- package/ajv/dist/ajv.module.js.map +1 -1
- package/ajv/dist/ajv.umd.js.map +1 -1
- package/ajv/src/ajv.ts +20 -0
- package/arktype/dist/arktype.d.ts +20 -2
- package/arktype/dist/arktype.js +1 -1
- package/arktype/dist/arktype.js.map +1 -1
- package/arktype/dist/arktype.mjs +1 -1
- package/arktype/dist/arktype.modern.mjs +1 -1
- package/arktype/dist/arktype.modern.mjs.map +1 -1
- package/arktype/dist/arktype.module.js +1 -1
- package/arktype/dist/arktype.module.js.map +1 -1
- package/arktype/dist/arktype.umd.js +1 -1
- package/arktype/dist/arktype.umd.js.map +1 -1
- package/arktype/dist/index.d.ts +0 -1
- package/arktype/src/__tests__/Form.tsx +32 -6
- package/arktype/src/__tests__/__fixtures__/data.ts +1 -1
- package/arktype/src/arktype.ts +29 -9
- package/arktype/src/index.ts +0 -1
- package/class-validator/dist/class-validator.d.ts +29 -2
- package/class-validator/dist/class-validator.js +1 -1
- package/class-validator/dist/class-validator.js.map +1 -1
- package/class-validator/dist/class-validator.mjs +1 -1
- package/class-validator/dist/class-validator.modern.mjs +1 -1
- package/class-validator/dist/class-validator.modern.mjs.map +1 -1
- package/class-validator/dist/class-validator.module.js +1 -1
- package/class-validator/dist/class-validator.module.js.map +1 -1
- package/class-validator/dist/class-validator.umd.js +1 -1
- package/class-validator/dist/class-validator.umd.js.map +1 -1
- package/class-validator/dist/index.d.ts +0 -1
- package/class-validator/src/__tests__/Form.tsx +26 -0
- package/class-validator/src/__tests__/__fixtures__/data.ts +1 -1
- package/class-validator/src/__tests__/class-validator.ts +21 -10
- package/class-validator/src/class-validator.ts +46 -12
- package/class-validator/src/index.ts +0 -1
- package/computed-types/dist/computed-types.d.ts +18 -2
- package/computed-types/dist/computed-types.js.map +1 -1
- package/computed-types/dist/computed-types.mjs +1 -1
- package/computed-types/dist/computed-types.modern.mjs +1 -1
- package/computed-types/dist/computed-types.modern.mjs.map +1 -1
- package/computed-types/dist/computed-types.module.js +1 -1
- package/computed-types/dist/computed-types.module.js.map +1 -1
- package/computed-types/dist/computed-types.umd.js.map +1 -1
- package/computed-types/dist/index.d.ts +0 -1
- package/computed-types/src/__tests__/Form-native-validation.tsx +2 -4
- package/computed-types/src/__tests__/Form.tsx +30 -6
- package/computed-types/src/__tests__/__fixtures__/data.ts +1 -1
- package/computed-types/src/__tests__/computed-types.ts +2 -0
- package/computed-types/src/computed-types.ts +24 -7
- package/computed-types/src/index.ts +0 -1
- package/effect-ts/dist/effect-ts.d.ts +19 -2
- package/effect-ts/dist/effect-ts.js.map +1 -1
- package/effect-ts/dist/effect-ts.mjs +1 -1
- package/effect-ts/dist/effect-ts.modern.mjs +1 -1
- package/effect-ts/dist/effect-ts.modern.mjs.map +1 -1
- package/effect-ts/dist/effect-ts.module.js +1 -1
- package/effect-ts/dist/effect-ts.module.js.map +1 -1
- package/effect-ts/dist/effect-ts.umd.js.map +1 -1
- package/effect-ts/dist/index.d.ts +0 -1
- package/effect-ts/src/__tests__/Form.tsx +30 -4
- package/effect-ts/src/__tests__/__fixtures__/data.ts +1 -1
- package/effect-ts/src/effect-ts.ts +30 -8
- package/effect-ts/src/index.ts +0 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.d.ts +21 -0
- package/fluentvalidation-ts/dist/fluentvalidation-ts.js +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.js.map +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.mjs +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.modern.mjs +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.modern.mjs.map +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.module.js +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.module.js.map +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.umd.js +1 -1
- package/fluentvalidation-ts/dist/fluentvalidation-ts.umd.js.map +1 -1
- package/fluentvalidation-ts/src/fluentvalidation-ts.ts +24 -3
- package/io-ts/dist/errorsToRecord.d.ts +5 -1
- package/io-ts/dist/index.d.ts +0 -1
- package/io-ts/dist/io-ts.d.ts +19 -2
- package/io-ts/dist/io-ts.js.map +1 -1
- package/io-ts/dist/io-ts.mjs +1 -1
- package/io-ts/dist/io-ts.modern.mjs +1 -1
- package/io-ts/dist/io-ts.modern.mjs.map +1 -1
- package/io-ts/dist/io-ts.module.js +1 -1
- package/io-ts/dist/io-ts.module.js.map +1 -1
- package/io-ts/dist/io-ts.umd.js.map +1 -1
- package/io-ts/src/__tests__/Form-native-validation.tsx +4 -11
- package/io-ts/src/__tests__/Form.tsx +30 -6
- package/io-ts/src/__tests__/__fixtures__/data.ts +2 -19
- package/io-ts/src/errorsToRecord.ts +4 -1
- package/io-ts/src/index.ts +0 -1
- package/io-ts/src/io-ts.ts +47 -25
- package/joi/dist/joi.d.ts +17 -0
- package/joi/dist/joi.js.map +1 -1
- package/joi/dist/joi.modern.mjs.map +1 -1
- package/joi/dist/joi.module.js.map +1 -1
- package/joi/dist/joi.umd.js.map +1 -1
- package/joi/src/joi.ts +17 -0
- package/nope/dist/nope.d.ts +17 -0
- package/nope/dist/nope.js +1 -1
- package/nope/dist/nope.js.map +1 -1
- package/nope/dist/nope.mjs +1 -1
- package/nope/dist/nope.modern.mjs.map +1 -1
- package/nope/dist/nope.module.js +1 -1
- package/nope/dist/nope.module.js.map +1 -1
- package/nope/dist/nope.umd.js +1 -1
- package/nope/dist/nope.umd.js.map +1 -1
- package/nope/src/nope.ts +17 -0
- package/package.json +5 -1
- package/standard-schema/dist/index.d.ts +0 -1
- package/standard-schema/dist/standard-schema.d.ts +25 -2
- package/standard-schema/dist/standard-schema.js +1 -1
- package/standard-schema/dist/standard-schema.js.map +1 -1
- package/standard-schema/dist/standard-schema.mjs +1 -1
- package/standard-schema/dist/standard-schema.modern.mjs +1 -1
- package/standard-schema/dist/standard-schema.modern.mjs.map +1 -1
- package/standard-schema/dist/standard-schema.module.js +1 -1
- package/standard-schema/dist/standard-schema.module.js.map +1 -1
- package/standard-schema/dist/standard-schema.umd.js +1 -1
- package/standard-schema/dist/standard-schema.umd.js.map +1 -1
- package/standard-schema/package.json +1 -0
- package/standard-schema/src/__tests__/Form.tsx +32 -6
- package/standard-schema/src/__tests__/__fixtures__/data.ts +67 -21
- package/standard-schema/src/__tests__/__snapshots__/standard-schema.ts.snap +222 -11
- package/standard-schema/src/__tests__/standard-schema.ts +49 -3
- package/standard-schema/src/index.ts +0 -1
- package/standard-schema/src/standard-schema.ts +54 -11
- package/superstruct/dist/index.d.ts +0 -1
- package/superstruct/dist/superstruct.d.ts +22 -2
- package/superstruct/dist/superstruct.js.map +1 -1
- package/superstruct/dist/superstruct.mjs +1 -1
- package/superstruct/dist/superstruct.modern.mjs +1 -1
- package/superstruct/dist/superstruct.modern.mjs.map +1 -1
- package/superstruct/dist/superstruct.module.js +1 -1
- package/superstruct/dist/superstruct.module.js.map +1 -1
- package/superstruct/dist/superstruct.umd.js.map +1 -1
- package/superstruct/src/__tests__/Form.tsx +26 -0
- package/superstruct/src/__tests__/__fixtures__/data.ts +1 -1
- package/superstruct/src/index.ts +0 -1
- package/superstruct/src/superstruct.ts +31 -9
- package/typanion/dist/index.d.ts +0 -1
- package/typanion/dist/typanion.d.ts +18 -2
- package/typanion/dist/typanion.js.map +1 -1
- package/typanion/dist/typanion.mjs +1 -1
- package/typanion/dist/typanion.modern.mjs +1 -1
- package/typanion/dist/typanion.modern.mjs.map +1 -1
- package/typanion/dist/typanion.module.js +1 -1
- package/typanion/dist/typanion.module.js.map +1 -1
- package/typanion/dist/typanion.umd.js.map +1 -1
- package/typanion/src/__tests__/Form-native-validation.tsx +6 -14
- package/typanion/src/__tests__/Form.tsx +32 -8
- package/typanion/src/__tests__/__fixtures__/data.ts +9 -9
- package/typanion/src/__tests__/typanion.ts +3 -3
- package/typanion/src/index.ts +0 -1
- package/typanion/src/typanion.ts +32 -9
- package/typebox/dist/index.d.ts +0 -1
- package/typebox/dist/typebox.d.ts +20 -2
- package/typebox/dist/typebox.js +1 -1
- package/typebox/dist/typebox.js.map +1 -1
- package/typebox/dist/typebox.mjs +1 -1
- package/typebox/dist/typebox.modern.mjs +1 -1
- package/typebox/dist/typebox.modern.mjs.map +1 -1
- package/typebox/dist/typebox.module.js +1 -1
- package/typebox/dist/typebox.module.js.map +1 -1
- package/typebox/dist/typebox.umd.js +1 -1
- package/typebox/dist/typebox.umd.js.map +1 -1
- package/typebox/src/__tests__/Form-compiler.tsx +4 -8
- package/typebox/src/__tests__/Form.tsx +32 -6
- package/typebox/src/__tests__/__fixtures__/data.ts +1 -1
- package/typebox/src/index.ts +0 -1
- package/typebox/src/typebox.ts +33 -7
- package/typeschema/dist/typeschema.d.ts +17 -0
- package/typeschema/dist/typeschema.js.map +1 -1
- package/typeschema/dist/typeschema.modern.mjs.map +1 -1
- package/typeschema/dist/typeschema.module.js.map +1 -1
- package/typeschema/dist/typeschema.umd.js.map +1 -1
- package/typeschema/src/typeschema.ts +17 -0
- package/valibot/dist/index.d.ts +0 -1
- package/valibot/dist/valibot.d.ts +31 -2
- package/valibot/dist/valibot.js.map +1 -1
- package/valibot/dist/valibot.mjs +1 -1
- package/valibot/dist/valibot.modern.mjs +1 -1
- package/valibot/dist/valibot.modern.mjs.map +1 -1
- package/valibot/dist/valibot.module.js +1 -1
- package/valibot/dist/valibot.module.js.map +1 -1
- package/valibot/dist/valibot.umd.js.map +1 -1
- package/valibot/src/__tests__/Form.tsx +26 -0
- package/valibot/src/__tests__/__fixtures__/data.ts +7 -3
- package/valibot/src/index.ts +0 -1
- package/valibot/src/valibot.ts +52 -5
- package/vest/dist/vest.d.ts +18 -0
- package/vest/dist/vest.js.map +1 -1
- package/vest/dist/vest.modern.mjs.map +1 -1
- package/vest/dist/vest.module.js.map +1 -1
- package/vest/dist/vest.umd.js.map +1 -1
- package/vest/src/vest.ts +18 -0
- package/vine/dist/index.d.ts +0 -1
- package/vine/dist/vine.d.ts +25 -2
- package/vine/dist/vine.js +1 -1
- package/vine/dist/vine.js.map +1 -1
- package/vine/dist/vine.mjs +1 -1
- package/vine/dist/vine.modern.mjs +1 -1
- package/vine/dist/vine.modern.mjs.map +1 -1
- package/vine/dist/vine.module.js +1 -1
- package/vine/dist/vine.module.js.map +1 -1
- package/vine/dist/vine.umd.js +1 -1
- package/vine/dist/vine.umd.js.map +1 -1
- package/vine/src/__tests__/Form-native-validation.tsx +2 -4
- package/vine/src/__tests__/Form.tsx +30 -6
- package/vine/src/__tests__/__fixtures__/data.ts +1 -1
- package/vine/src/index.ts +0 -1
- package/vine/src/vine.ts +37 -9
- package/yup/dist/yup.d.ts +18 -7
- package/yup/dist/yup.js.map +1 -1
- package/yup/dist/yup.modern.mjs.map +1 -1
- package/yup/dist/yup.module.js.map +1 -1
- package/yup/dist/yup.umd.js.map +1 -1
- package/yup/src/yup.ts +21 -10
- package/zod/dist/index.d.ts +0 -1
- package/zod/dist/zod.d.ts +25 -2
- package/zod/dist/zod.js +1 -1
- package/zod/dist/zod.js.map +1 -1
- package/zod/dist/zod.mjs +1 -1
- package/zod/dist/zod.modern.mjs +1 -1
- package/zod/dist/zod.modern.mjs.map +1 -1
- package/zod/dist/zod.module.js +1 -1
- package/zod/dist/zod.module.js.map +1 -1
- package/zod/dist/zod.umd.js +1 -1
- package/zod/dist/zod.umd.js.map +1 -1
- package/zod/src/__tests__/Form.tsx +30 -6
- package/zod/src/__tests__/__fixtures__/data.ts +3 -3
- package/zod/src/index.ts +0 -1
- package/zod/src/zod.ts +39 -8
- package/arktype/dist/types.d.ts +0 -9
- package/arktype/src/types.ts +0 -18
- package/class-validator/dist/types.d.ts +0 -12
- package/class-validator/src/types.ts +0 -16
- package/computed-types/dist/types.d.ts +0 -2
- package/computed-types/src/types.ts +0 -13
- package/effect-ts/dist/types.d.ts +0 -4
- package/effect-ts/src/types.ts +0 -12
- package/io-ts/dist/types.d.ts +0 -7
- package/io-ts/src/types.ts +0 -18
- package/standard-schema/dist/types.d.ts +0 -3
- package/standard-schema/src/types.ts +0 -10
- package/superstruct/dist/types.d.ts +0 -11
- package/superstruct/src/types.ts +0 -20
- package/typanion/dist/types.d.ts +0 -9
- package/typanion/src/types.ts +0 -20
- package/typebox/dist/types.d.ts +0 -4
- package/typebox/src/types.ts +0 -11
- package/valibot/dist/types.d.ts +0 -13
- package/valibot/src/types.ts +0 -34
- package/vine/dist/types.d.ts +0 -6
- package/vine/src/types.ts +0 -13
- package/zod/dist/types.d.ts +0 -13
- package/zod/src/types.ts +0 -22
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{plainToClass as t}from"class-transformer";import{validateSync as o,validate as n}from"class-validator";
|
|
1
|
+
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{plainToClass as t}from"class-transformer";import{validateSync as o,validate as n}from"class-validator";function s(r,e,t,o){return void 0===t&&(t={}),void 0===o&&(o=""),r.reduce(function(r,t){var n=o?o+"."+t.property:t.property;if(t.constraints){var i=Object.keys(t.constraints)[0];r[n]={type:i,message:t.constraints[i]};var a=r[n];e&&a&&Object.assign(a,{types:t.constraints})}return t.children&&t.children.length&&s(t.children,e,r,n),r},t)}function i(i,a,c){return void 0===a&&(a={}),void 0===c&&(c={}),function(l,d,u){try{var v=a.validator,m=t(i,l,a.transformer);return Promise.resolve(("sync"===c.mode?o:n)(m,v)).then(function(t){return t.length?{values:{},errors:r(s(t,!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)}:(u.shouldUseNativeValidation&&e({},u),{values:c.raw?Object.assign({},l):m,errors:{}})})}catch(r){return Promise.reject(r)}}}export{i as classValidatorResolver};
|
|
2
2
|
//# sourceMappingURL=class-validator.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-validator.module.js","sources":["../src/class-validator.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {
|
|
1
|
+
{"version":3,"file":"class-validator.module.js","sources":["../src/class-validator.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n ClassConstructor,\n ClassTransformOptions,\n plainToClass,\n} from 'class-transformer';\nimport {\n ValidationError,\n ValidatorOptions,\n validate,\n validateSync,\n} from 'class-validator';\nimport { FieldErrors, Resolver } from 'react-hook-form';\n\nfunction parseErrorSchema(\n errors: ValidationError[],\n validateAllFieldCriteria: boolean,\n parsedErrors: FieldErrors = {},\n path = '',\n) {\n return errors.reduce((acc, error) => {\n const _path = path ? `${path}.${error.property}` : error.property;\n\n if (error.constraints) {\n const key = Object.keys(error.constraints)[0];\n acc[_path] = {\n type: key,\n message: error.constraints[key],\n };\n\n const _e = acc[_path];\n if (validateAllFieldCriteria && _e) {\n Object.assign(_e, { types: error.constraints });\n }\n }\n\n if (error.children && error.children.length) {\n parseErrorSchema(error.children, validateAllFieldCriteria, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n}\n\n/**\n * Creates a resolver for react-hook-form using class-validator schema validation\n * @param {ClassConstructor<Schema>} schema - The class-validator schema to validate against\n * @param {Object} schemaOptions - Additional schema validation options\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver<Schema>} A resolver function compatible with react-hook-form\n * @example\n * class Schema {\n * @Matches(/^\\w+$/)\n * @Length(3, 30)\n * username: string;\n * age: number\n * }\n *\n * useForm({\n * resolver: classValidatorResolver(Schema)\n * });\n */\nexport function classValidatorResolver<Schema extends Record<string, any>>(\n schema: ClassConstructor<Schema>,\n schemaOptions: {\n validator?: ValidatorOptions;\n transformer?: ClassTransformOptions;\n } = {},\n resolverOptions: { mode?: 'async' | 'sync'; raw?: boolean } = {},\n): Resolver<Schema> {\n return async (values, _, options) => {\n const { transformer, validator } = schemaOptions;\n const data = plainToClass(schema, values, transformer);\n\n const rawErrors = await (resolverOptions.mode === 'sync'\n ? validateSync\n : validate)(data, validator);\n\n if (rawErrors.length) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n rawErrors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n errors: {},\n };\n };\n}\n"],"names":["parseErrorSchema","errors","validateAllFieldCriteria","parsedErrors","path","reduce","acc","error","_path","property","constraints","key","Object","keys","type","message","_e","assign","types","children","length","classValidatorResolver","schema","schemaOptions","resolverOptions","values","_","options","validator","data","plainToClass","transformer","Promise","resolve","mode","validateSync","validate","then","rawErrors","toNestErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","raw","e","reject"],"mappings":"6LAcA,SAASA,EACPC,EACAC,EACAC,EACAC,GAEA,YAHA,IAAAD,IAAAA,EAA4B,CAAE,YAC9BC,IAAAA,EAAO,IAEAH,EAAOI,OAAO,SAACC,EAAKC,GACzB,IAAMC,EAAQJ,EAAUA,EAAI,IAAIG,EAAME,SAAaF,EAAME,SAEzD,GAAIF,EAAMG,YAAa,CACrB,IAAMC,EAAMC,OAAOC,KAAKN,EAAMG,aAAa,GAC3CJ,EAAIE,GAAS,CACXM,KAAMH,EACNI,QAASR,EAAMG,YAAYC,IAG7B,IAAMK,EAAKV,EAAIE,GACXN,GAA4Bc,GAC9BJ,OAAOK,OAAOD,EAAI,CAAEE,MAAOX,EAAMG,aAErC,CAMA,OAJIH,EAAMY,UAAYZ,EAAMY,SAASC,QACnCpB,EAAiBO,EAAMY,SAAUjB,EAA0BI,EAAKE,GAG3DF,CACT,EAAGH,EACL,CAqBM,SAAUkB,EACdC,EACAC,EAIAC,GAEA,gBANAD,IAAAA,EAGI,CAAE,QACN,IAAAC,IAAAA,EAA8D,CAAE,GAEhE,SAAcC,EAAQC,EAAGC,OACvB,IAAqBC,EAAcL,EAAdK,UACfC,EAAOC,EAAaR,EAAQG,EADCF,EAA3BQ,aAC+C,OAAAC,QAAAC,SAEL,SAAzBT,EAAgBU,KACrCC,EACAC,GAAUP,EAAMD,IAAUS,KAFxBC,SAAAA,GAIN,OAAIA,EAAUlB,OACL,CACLK,OAAQ,CAAA,EACRxB,OAAQsC,EACNvC,EACEsC,GACCX,EAAQa,2BACkB,QAAzBb,EAAQc,cAEZd,KAKNA,EAAQa,2BAA6BE,EAAuB,CAAE,EAAEf,GAEzD,CACLF,OAAQD,EAAgBmB,IAAM/B,OAAOK,OAAO,CAAE,EAAEQ,GAAUI,EAC1D5B,OAAQ,CAAA,GACR,EACJ,CAAC,MAAA2C,GAAAZ,OAAAA,QAAAa,OAAAD,EACH,CAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("class-transformer"),require("class-validator")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","class-transformer","class-validator"],r):r((e||self).hookformResolversClassValidator={},e.hookformResolvers,e.classTransformer,e.classValidator)}(this,function(e,r,o,s){
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("class-transformer"),require("class-validator")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","class-transformer","class-validator"],r):r((e||self).hookformResolversClassValidator={},e.hookformResolvers,e.classTransformer,e.classValidator)}(this,function(e,r,o,s){function t(e,r,o,s){return void 0===o&&(o={}),void 0===s&&(s=""),e.reduce(function(e,o){var a=s?s+"."+o.property:o.property;if(o.constraints){var i=Object.keys(o.constraints)[0];e[a]={type:i,message:o.constraints[i]};var n=e[a];r&&n&&Object.assign(n,{types:o.constraints})}return o.children&&o.children.length&&t(o.children,r,e,a),e},o)}e.classValidatorResolver=function(e,a,i){return void 0===a&&(a={}),void 0===i&&(i={}),function(n,l,c){try{var d=a.validator,f=o.plainToClass(e,n,a.transformer);return Promise.resolve(("sync"===i.mode?s.validateSync:s.validate)(f,d)).then(function(e){return e.length?{values:{},errors:r.toNestErrors(t(e,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)}:(c.shouldUseNativeValidation&&r.validateFieldsNatively({},c),{values:i.raw?Object.assign({},n):f,errors:{}})})}catch(e){return Promise.reject(e)}}}});
|
|
2
2
|
//# sourceMappingURL=class-validator.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-validator.umd.js","sources":["../src/class-validator.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {
|
|
1
|
+
{"version":3,"file":"class-validator.umd.js","sources":["../src/class-validator.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n ClassConstructor,\n ClassTransformOptions,\n plainToClass,\n} from 'class-transformer';\nimport {\n ValidationError,\n ValidatorOptions,\n validate,\n validateSync,\n} from 'class-validator';\nimport { FieldErrors, Resolver } from 'react-hook-form';\n\nfunction parseErrorSchema(\n errors: ValidationError[],\n validateAllFieldCriteria: boolean,\n parsedErrors: FieldErrors = {},\n path = '',\n) {\n return errors.reduce((acc, error) => {\n const _path = path ? `${path}.${error.property}` : error.property;\n\n if (error.constraints) {\n const key = Object.keys(error.constraints)[0];\n acc[_path] = {\n type: key,\n message: error.constraints[key],\n };\n\n const _e = acc[_path];\n if (validateAllFieldCriteria && _e) {\n Object.assign(_e, { types: error.constraints });\n }\n }\n\n if (error.children && error.children.length) {\n parseErrorSchema(error.children, validateAllFieldCriteria, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n}\n\n/**\n * Creates a resolver for react-hook-form using class-validator schema validation\n * @param {ClassConstructor<Schema>} schema - The class-validator schema to validate against\n * @param {Object} schemaOptions - Additional schema validation options\n * @param {Object} resolverOptions - Additional resolver configuration\n * @param {string} [resolverOptions.mode='async'] - Validation mode\n * @returns {Resolver<Schema>} A resolver function compatible with react-hook-form\n * @example\n * class Schema {\n * @Matches(/^\\w+$/)\n * @Length(3, 30)\n * username: string;\n * age: number\n * }\n *\n * useForm({\n * resolver: classValidatorResolver(Schema)\n * });\n */\nexport function classValidatorResolver<Schema extends Record<string, any>>(\n schema: ClassConstructor<Schema>,\n schemaOptions: {\n validator?: ValidatorOptions;\n transformer?: ClassTransformOptions;\n } = {},\n resolverOptions: { mode?: 'async' | 'sync'; raw?: boolean } = {},\n): Resolver<Schema> {\n return async (values, _, options) => {\n const { transformer, validator } = schemaOptions;\n const data = plainToClass(schema, values, transformer);\n\n const rawErrors = await (resolverOptions.mode === 'sync'\n ? validateSync\n : validate)(data, validator);\n\n if (rawErrors.length) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n rawErrors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n errors: {},\n };\n };\n}\n"],"names":["parseErrorSchema","errors","validateAllFieldCriteria","parsedErrors","path","reduce","acc","error","_path","property","constraints","key","Object","keys","type","message","_e","assign","types","children","length","schema","schemaOptions","resolverOptions","values","_","options","validator","data","plainToClass","transformer","Promise","resolve","mode","validateSync","validate","then","rawErrors","toNestErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","raw","e","reject"],"mappings":"0cAcA,SAASA,EACPC,EACAC,EACAC,EACAC,GAEA,YAHA,IAAAD,IAAAA,EAA4B,CAAE,YAC9BC,IAAAA,EAAO,IAEAH,EAAOI,OAAO,SAACC,EAAKC,GACzB,IAAMC,EAAQJ,EAAUA,EAAI,IAAIG,EAAME,SAAaF,EAAME,SAEzD,GAAIF,EAAMG,YAAa,CACrB,IAAMC,EAAMC,OAAOC,KAAKN,EAAMG,aAAa,GAC3CJ,EAAIE,GAAS,CACXM,KAAMH,EACNI,QAASR,EAAMG,YAAYC,IAG7B,IAAMK,EAAKV,EAAIE,GACXN,GAA4Bc,GAC9BJ,OAAOK,OAAOD,EAAI,CAAEE,MAAOX,EAAMG,aAErC,CAMA,OAJIH,EAAMY,UAAYZ,EAAMY,SAASC,QACnCpB,EAAiBO,EAAMY,SAAUjB,EAA0BI,EAAKE,GAG3DF,CACT,EAAGH,EACL,0BAqBM,SACJkB,EACAC,EAIAC,GAEA,gBANAD,IAAAA,EAGI,CAAE,QACN,IAAAC,IAAAA,EAA8D,CAAE,GAEhE,SAAcC,EAAQC,EAAGC,OACvB,IAAqBC,EAAcL,EAAdK,UACfC,EAAOC,EAAYA,aAACR,EAAQG,EADCF,EAA3BQ,aAC+C,OAAAC,QAAAC,SAEL,SAAzBT,EAAgBU,KACrCC,eACAC,EAAAA,UAAUP,EAAMD,IAAUS,KAFxBC,SAAAA,GAIN,OAAIA,EAAUjB,OACL,CACLI,OAAQ,CAAA,EACRvB,OAAQqC,eACNtC,EACEqC,GACCX,EAAQa,2BACkB,QAAzBb,EAAQc,cAEZd,KAKNA,EAAQa,2BAA6BE,EAAsBA,uBAAC,CAAE,EAAEf,GAEzD,CACLF,OAAQD,EAAgBmB,IAAM9B,OAAOK,OAAO,CAAE,EAAEO,GAAUI,EAC1D3B,OAAQ,CAAA,GACR,EACJ,CAAC,MAAA0C,GAAAZ,OAAAA,QAAAa,OAAAD,EACH,CAAA,CAAA"}
|
|
@@ -51,3 +51,29 @@ test("form's validation with Class Validator and TypeScript's integration", asyn
|
|
|
51
51
|
expect(screen.getByText(/password should not be empty/i)).toBeInTheDocument();
|
|
52
52
|
expect(handleSubmit).not.toHaveBeenCalled();
|
|
53
53
|
});
|
|
54
|
+
|
|
55
|
+
export function TestComponentManualType({
|
|
56
|
+
onSubmit,
|
|
57
|
+
}: {
|
|
58
|
+
onSubmit: (data: FormData) => void;
|
|
59
|
+
}) {
|
|
60
|
+
const {
|
|
61
|
+
register,
|
|
62
|
+
handleSubmit,
|
|
63
|
+
formState: { errors },
|
|
64
|
+
} = useForm<Schema, undefined, FormData>({
|
|
65
|
+
resolver: classValidatorResolver(Schema), // Useful to check TypeScript regressions
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
70
|
+
<input {...register('username')} />
|
|
71
|
+
{errors.username && <span role="alert">{errors.username.message}</span>}
|
|
72
|
+
|
|
73
|
+
<input {...register('password')} />
|
|
74
|
+
{errors.password && <span role="alert">{errors.password.message}</span>}
|
|
75
|
+
|
|
76
|
+
<button type="submit">submit</button>
|
|
77
|
+
</form>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -122,11 +122,16 @@ it('validate data with transformer option', async () => {
|
|
|
122
122
|
{
|
|
123
123
|
mode: 'sync',
|
|
124
124
|
},
|
|
125
|
-
)(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
)(
|
|
126
|
+
// @ts-expect-error - Just for testing purposes
|
|
127
|
+
invalidData,
|
|
128
|
+
undefined,
|
|
129
|
+
{
|
|
130
|
+
fields,
|
|
131
|
+
criteriaMode: 'all',
|
|
132
|
+
shouldUseNativeValidation,
|
|
133
|
+
},
|
|
134
|
+
);
|
|
130
135
|
|
|
131
136
|
expect(result).toMatchSnapshot();
|
|
132
137
|
});
|
|
@@ -151,11 +156,16 @@ it('validate data with validator option', async () => {
|
|
|
151
156
|
{
|
|
152
157
|
mode: 'sync',
|
|
153
158
|
},
|
|
154
|
-
)(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
)(
|
|
160
|
+
// @ts-expect-error - Just for testing purposes
|
|
161
|
+
invalidData,
|
|
162
|
+
undefined,
|
|
163
|
+
{
|
|
164
|
+
fields,
|
|
165
|
+
criteriaMode: 'all',
|
|
166
|
+
shouldUseNativeValidation,
|
|
167
|
+
},
|
|
168
|
+
);
|
|
159
169
|
|
|
160
170
|
expect(result).toMatchSnapshot();
|
|
161
171
|
});
|
|
@@ -174,6 +184,7 @@ it('should return from classValidatorResolver with `excludeExtraneousValues` set
|
|
|
174
184
|
})(
|
|
175
185
|
{
|
|
176
186
|
random: 10,
|
|
187
|
+
// @ts-expect-error - Just for testing purposes
|
|
177
188
|
extraneousField: true,
|
|
178
189
|
},
|
|
179
190
|
undefined,
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {
|
|
3
|
+
ClassConstructor,
|
|
4
|
+
ClassTransformOptions,
|
|
5
|
+
plainToClass,
|
|
6
|
+
} from 'class-transformer';
|
|
7
|
+
import {
|
|
8
|
+
ValidationError,
|
|
9
|
+
ValidatorOptions,
|
|
10
|
+
validate,
|
|
11
|
+
validateSync,
|
|
12
|
+
} from 'class-validator';
|
|
13
|
+
import { FieldErrors, Resolver } from 'react-hook-form';
|
|
6
14
|
|
|
7
|
-
|
|
15
|
+
function parseErrorSchema(
|
|
8
16
|
errors: ValidationError[],
|
|
9
17
|
validateAllFieldCriteria: boolean,
|
|
10
18
|
parsedErrors: FieldErrors = {},
|
|
11
19
|
path = '',
|
|
12
|
-
)
|
|
20
|
+
) {
|
|
13
21
|
return errors.reduce((acc, error) => {
|
|
14
22
|
const _path = path ? `${path}.${error.property}` : error.property;
|
|
15
23
|
|
|
@@ -27,16 +35,41 @@ const parseErrors = (
|
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
if (error.children && error.children.length) {
|
|
30
|
-
|
|
38
|
+
parseErrorSchema(error.children, validateAllFieldCriteria, acc, _path);
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
return acc;
|
|
34
42
|
}, parsedErrors);
|
|
35
|
-
}
|
|
43
|
+
}
|
|
36
44
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Creates a resolver for react-hook-form using class-validator schema validation
|
|
47
|
+
* @param {ClassConstructor<Schema>} schema - The class-validator schema to validate against
|
|
48
|
+
* @param {Object} schemaOptions - Additional schema validation options
|
|
49
|
+
* @param {Object} resolverOptions - Additional resolver configuration
|
|
50
|
+
* @param {string} [resolverOptions.mode='async'] - Validation mode
|
|
51
|
+
* @returns {Resolver<Schema>} A resolver function compatible with react-hook-form
|
|
52
|
+
* @example
|
|
53
|
+
* class Schema {
|
|
54
|
+
* @Matches(/^\w+$/)
|
|
55
|
+
* @Length(3, 30)
|
|
56
|
+
* username: string;
|
|
57
|
+
* age: number
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* useForm({
|
|
61
|
+
* resolver: classValidatorResolver(Schema)
|
|
62
|
+
* });
|
|
63
|
+
*/
|
|
64
|
+
export function classValidatorResolver<Schema extends Record<string, any>>(
|
|
65
|
+
schema: ClassConstructor<Schema>,
|
|
66
|
+
schemaOptions: {
|
|
67
|
+
validator?: ValidatorOptions;
|
|
68
|
+
transformer?: ClassTransformOptions;
|
|
69
|
+
} = {},
|
|
70
|
+
resolverOptions: { mode?: 'async' | 'sync'; raw?: boolean } = {},
|
|
71
|
+
): Resolver<Schema> {
|
|
72
|
+
return async (values, _, options) => {
|
|
40
73
|
const { transformer, validator } = schemaOptions;
|
|
41
74
|
const data = plainToClass(schema, values, transformer);
|
|
42
75
|
|
|
@@ -48,7 +81,7 @@ export const classValidatorResolver: Resolver =
|
|
|
48
81
|
return {
|
|
49
82
|
values: {},
|
|
50
83
|
errors: toNestErrors(
|
|
51
|
-
|
|
84
|
+
parseErrorSchema(
|
|
52
85
|
rawErrors,
|
|
53
86
|
!options.shouldUseNativeValidation &&
|
|
54
87
|
options.criteriaMode === 'all',
|
|
@@ -65,3 +98,4 @@ export const classValidatorResolver: Resolver =
|
|
|
65
98
|
errors: {},
|
|
66
99
|
};
|
|
67
100
|
};
|
|
101
|
+
}
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Type } from 'computed-types';
|
|
2
|
+
import FunctionType from 'computed-types/lib/schema/FunctionType';
|
|
3
|
+
import type { Resolver } from 'react-hook-form';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a resolver for react-hook-form using computed-types schema validation
|
|
6
|
+
* @param {Schema} schema - The computed-types schema to validate against
|
|
7
|
+
* @returns {Resolver<Type<typeof schema>>} A resolver function compatible with react-hook-form
|
|
8
|
+
* @example
|
|
9
|
+
* const schema = Schema({
|
|
10
|
+
* name: string,
|
|
11
|
+
* age: number
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* useForm({
|
|
15
|
+
* resolver: computedTypesResolver(schema)
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
export declare function computedTypesResolver<Schema extends FunctionType<any, any>>(schema: Schema): Resolver<Type<typeof schema>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed-types.js","sources":["../src/computed-types.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport
|
|
1
|
+
{"version":3,"file":"computed-types.js","sources":["../src/computed-types.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { Type, ValidationError } from 'computed-types';\nimport FunctionType from 'computed-types/lib/schema/FunctionType';\nimport type { FieldErrors, Resolver } from 'react-hook-form';\n\nconst isValidationError = (error: any): error is ValidationError =>\n error.errors != null;\n\nfunction parseErrorSchema(computedTypesError: ValidationError) {\n const parsedErrors: FieldErrors = {};\n return (computedTypesError.errors || []).reduce((acc, error) => {\n acc[error.path.join('.')] = {\n type: error.error.name,\n message: error.error.message,\n };\n\n return acc;\n }, parsedErrors);\n}\n\n/**\n * Creates a resolver for react-hook-form using computed-types schema validation\n * @param {Schema} schema - The computed-types schema to validate against\n * @returns {Resolver<Type<typeof schema>>} A resolver function compatible with react-hook-form\n * @example\n * const schema = Schema({\n * name: string,\n * age: number\n * });\n *\n * useForm({\n * resolver: computedTypesResolver(schema)\n * });\n */\nexport function computedTypesResolver<Schema extends FunctionType<any, any>>(\n schema: Schema,\n): Resolver<Type<typeof schema>> {\n return async (values, _, options) => {\n try {\n const data = await schema(values);\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: data,\n };\n } catch (error: any) {\n if (isValidationError(error)) {\n return {\n values: {},\n errors: toNestErrors(parseErrorSchema(error), options),\n };\n }\n\n throw error;\n }\n };\n}\n"],"names":["schema","values","_","options","Promise","resolve","then","data","shouldUseNativeValidation","validateFieldsNatively","errors","_catch","error","isValidationError","toNestErrors","computedTypesError","reduce","acc","path","join","type","name","message","e","reject"],"mappings":"mEAkCM,SACJA,GAEA,OAAcC,SAAAA,EAAQC,EAAGC,GAAW,IAAA,OAAAC,QAAAC,gCAC9BD,QAAAC,QACiBL,EAAOC,IAAOK,KAAA,SAA3BC,GAIN,OAFAJ,EAAQK,2BAA6BC,EAAAA,uBAAuB,CAAA,EAAIN,GAEzD,CACLO,OAAQ,CAAA,EACRT,OAAQM,EACR,4DAT8BI,CAAA,EAUjC,SAAQC,GACP,GA3CoB,SAACA,GACzB,OAAgB,MAAhBA,EAAMF,MAAc,CA0CZG,CAAkBD,GACpB,MAAO,CACLX,OAAQ,CAAE,EACVS,OAAQI,gBA3CQC,EA2CsBH,GAzCtCG,EAAmBL,QAAU,IAAIM,OAAO,SAACC,EAAKL,GAMpD,OALAK,EAAIL,EAAMM,KAAKC,KAAK,MAAQ,CAC1BC,KAAMR,EAAMA,MAAMS,KAClBC,QAASV,EAAMA,MAAMU,SAGhBL,CACT,EARkC,CAAE,IA0CkBd,IA3CxD,IAA0BY,EA+CpB,MAAMH,CACR,GACF,CAAC,MAAAW,GAAAnB,OAAAA,QAAAoB,OAAAD,EACH,CAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";
|
|
1
|
+
import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";function t(t){return function(n,o,u){try{return Promise.resolve(function(e,o){try{var s=Promise.resolve(t(n)).then(function(e){return u.shouldUseNativeValidation&&r({},u),{errors:{},values:e}})}catch(r){return o(r)}return s&&s.then?s.then(void 0,o):s}(0,function(r){if(function(r){return null!=r.errors}(r))return{values:{},errors:e((t=r,(t.errors||[]).reduce(function(r,e){return r[e.path.join(".")]={type:e.error.name,message:e.error.message},r},{})),u)};var t;throw r}))}catch(r){return Promise.reject(r)}}}export{t as computedTypesResolver};
|
|
2
2
|
//# sourceMappingURL=computed-types.module.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";
|
|
1
|
+
import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";function o(o){return async(s,t,a)=>{try{const e=await o(s);return a.shouldUseNativeValidation&&r({},a),{errors:{},values:e}}catch(r){if((r=>null!=r.errors)(r))return{values:{},errors:e((n=r,(n.errors||[]).reduce((r,e)=>(r[e.path.join(".")]={type:e.error.name,message:e.error.message},r),{})),a)};throw r}var n}}export{o as computedTypesResolver};
|
|
2
2
|
//# sourceMappingURL=computed-types.modern.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed-types.modern.mjs","sources":["../src/computed-types.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport
|
|
1
|
+
{"version":3,"file":"computed-types.modern.mjs","sources":["../src/computed-types.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { Type, ValidationError } from 'computed-types';\nimport FunctionType from 'computed-types/lib/schema/FunctionType';\nimport type { FieldErrors, Resolver } from 'react-hook-form';\n\nconst isValidationError = (error: any): error is ValidationError =>\n error.errors != null;\n\nfunction parseErrorSchema(computedTypesError: ValidationError) {\n const parsedErrors: FieldErrors = {};\n return (computedTypesError.errors || []).reduce((acc, error) => {\n acc[error.path.join('.')] = {\n type: error.error.name,\n message: error.error.message,\n };\n\n return acc;\n }, parsedErrors);\n}\n\n/**\n * Creates a resolver for react-hook-form using computed-types schema validation\n * @param {Schema} schema - The computed-types schema to validate against\n * @returns {Resolver<Type<typeof schema>>} A resolver function compatible with react-hook-form\n * @example\n * const schema = Schema({\n * name: string,\n * age: number\n * });\n *\n * useForm({\n * resolver: computedTypesResolver(schema)\n * });\n */\nexport function computedTypesResolver<Schema extends FunctionType<any, any>>(\n schema: Schema,\n): Resolver<Type<typeof schema>> {\n return async (values, _, options) => {\n try {\n const data = await schema(values);\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: data,\n };\n } catch (error: any) {\n if (isValidationError(error)) {\n return {\n values: {},\n errors: toNestErrors(parseErrorSchema(error), options),\n };\n }\n\n throw error;\n }\n };\n}\n"],"names":["computedTypesResolver","schema","values","_","options","data","shouldUseNativeValidation","validateFieldsNatively","errors","error","isValidationError","toNestErrors","computedTypesError","reduce","acc","path","join","type","name","message"],"mappings":"+EAkCgB,SAAAA,EACdC,GAEA,aAAcC,EAAQC,EAAGC,KACvB,IACE,MAAMC,QAAaJ,EAAOC,GAI1B,OAFAE,EAAQE,2BAA6BC,EAAuB,CAAA,EAAIH,GAEzD,CACLI,OAAQ,CAAE,EACVN,OAAQG,EAEZ,CAAE,MAAOI,GACP,GA3CqBA,IACT,MAAhBA,EAAMD,OA0CEE,CAAkBD,GACpB,MAAO,CACLP,OAAQ,CAAE,EACVM,OAAQG,GA3CQC,EA2CsBH,GAzCtCG,EAAmBJ,QAAU,IAAIK,OAAO,CAACC,EAAKL,KACpDK,EAAIL,EAAMM,KAAKC,KAAK,MAAQ,CAC1BC,KAAMR,EAAMA,MAAMS,KAClBC,QAASV,EAAMA,MAAMU,SAGhBL,GAPyB,KA0CoBV,IAIlD,MAAMK,CACR,CAhDJ,IAA0BG,CAgDtB,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";
|
|
1
|
+
import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";function t(t){return function(n,o,u){try{return Promise.resolve(function(e,o){try{var s=Promise.resolve(t(n)).then(function(e){return u.shouldUseNativeValidation&&r({},u),{errors:{},values:e}})}catch(r){return o(r)}return s&&s.then?s.then(void 0,o):s}(0,function(r){if(function(r){return null!=r.errors}(r))return{values:{},errors:e((t=r,(t.errors||[]).reduce(function(r,e){return r[e.path.join(".")]={type:e.error.name,message:e.error.message},r},{})),u)};var t;throw r}))}catch(r){return Promise.reject(r)}}}export{t as computedTypesResolver};
|
|
2
2
|
//# sourceMappingURL=computed-types.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed-types.module.js","sources":["../src/computed-types.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport
|
|
1
|
+
{"version":3,"file":"computed-types.module.js","sources":["../src/computed-types.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { Type, ValidationError } from 'computed-types';\nimport FunctionType from 'computed-types/lib/schema/FunctionType';\nimport type { FieldErrors, Resolver } from 'react-hook-form';\n\nconst isValidationError = (error: any): error is ValidationError =>\n error.errors != null;\n\nfunction parseErrorSchema(computedTypesError: ValidationError) {\n const parsedErrors: FieldErrors = {};\n return (computedTypesError.errors || []).reduce((acc, error) => {\n acc[error.path.join('.')] = {\n type: error.error.name,\n message: error.error.message,\n };\n\n return acc;\n }, parsedErrors);\n}\n\n/**\n * Creates a resolver for react-hook-form using computed-types schema validation\n * @param {Schema} schema - The computed-types schema to validate against\n * @returns {Resolver<Type<typeof schema>>} A resolver function compatible with react-hook-form\n * @example\n * const schema = Schema({\n * name: string,\n * age: number\n * });\n *\n * useForm({\n * resolver: computedTypesResolver(schema)\n * });\n */\nexport function computedTypesResolver<Schema extends FunctionType<any, any>>(\n schema: Schema,\n): Resolver<Type<typeof schema>> {\n return async (values, _, options) => {\n try {\n const data = await schema(values);\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: data,\n };\n } catch (error: any) {\n if (isValidationError(error)) {\n return {\n values: {},\n errors: toNestErrors(parseErrorSchema(error), options),\n };\n }\n\n throw error;\n }\n };\n}\n"],"names":["computedTypesResolver","schema","values","_","options","Promise","resolve","then","data","shouldUseNativeValidation","validateFieldsNatively","errors","_catch","error","isValidationError","toNestErrors","computedTypesError","reduce","acc","path","join","type","name","message","e","reject"],"mappings":"+EAkCM,SAAUA,EACdC,GAEA,OAAcC,SAAAA,EAAQC,EAAGC,GAAW,IAAA,OAAAC,QAAAC,gCAC9BD,QAAAC,QACiBL,EAAOC,IAAOK,KAAA,SAA3BC,GAIN,OAFAJ,EAAQK,2BAA6BC,EAAuB,CAAA,EAAIN,GAEzD,CACLO,OAAQ,CAAA,EACRT,OAAQM,EACR,4DAT8BI,CAAA,EAUjC,SAAQC,GACP,GA3CoB,SAACA,GACzB,OAAgB,MAAhBA,EAAMF,MAAc,CA0CZG,CAAkBD,GACpB,MAAO,CACLX,OAAQ,CAAE,EACVS,OAAQI,GA3CQC,EA2CsBH,GAzCtCG,EAAmBL,QAAU,IAAIM,OAAO,SAACC,EAAKL,GAMpD,OALAK,EAAIL,EAAMM,KAAKC,KAAK,MAAQ,CAC1BC,KAAMR,EAAMA,MAAMS,KAClBC,QAASV,EAAMA,MAAMU,SAGhBL,CACT,EARkC,CAAE,IA0CkBd,IA3CxD,IAA0BY,EA+CpB,MAAMH,CACR,GACF,CAAC,MAAAW,GAAAnB,OAAAA,QAAAoB,OAAAD,EACH,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed-types.umd.js","sources":["../src/computed-types.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport
|
|
1
|
+
{"version":3,"file":"computed-types.umd.js","sources":["../src/computed-types.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { Type, ValidationError } from 'computed-types';\nimport FunctionType from 'computed-types/lib/schema/FunctionType';\nimport type { FieldErrors, Resolver } from 'react-hook-form';\n\nconst isValidationError = (error: any): error is ValidationError =>\n error.errors != null;\n\nfunction parseErrorSchema(computedTypesError: ValidationError) {\n const parsedErrors: FieldErrors = {};\n return (computedTypesError.errors || []).reduce((acc, error) => {\n acc[error.path.join('.')] = {\n type: error.error.name,\n message: error.error.message,\n };\n\n return acc;\n }, parsedErrors);\n}\n\n/**\n * Creates a resolver for react-hook-form using computed-types schema validation\n * @param {Schema} schema - The computed-types schema to validate against\n * @returns {Resolver<Type<typeof schema>>} A resolver function compatible with react-hook-form\n * @example\n * const schema = Schema({\n * name: string,\n * age: number\n * });\n *\n * useForm({\n * resolver: computedTypesResolver(schema)\n * });\n */\nexport function computedTypesResolver<Schema extends FunctionType<any, any>>(\n schema: Schema,\n): Resolver<Type<typeof schema>> {\n return async (values, _, options) => {\n try {\n const data = await schema(values);\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n errors: {},\n values: data,\n };\n } catch (error: any) {\n if (isValidationError(error)) {\n return {\n values: {},\n errors: toNestErrors(parseErrorSchema(error), options),\n };\n }\n\n throw error;\n }\n };\n}\n"],"names":["schema","values","_","options","Promise","resolve","then","data","shouldUseNativeValidation","validateFieldsNatively","errors","_catch","error","isValidationError","toNestErrors","computedTypesError","reduce","acc","path","join","type","name","message","e","reject"],"mappings":"2VAkCM,SACJA,GAEA,OAAcC,SAAAA,EAAQC,EAAGC,GAAW,IAAA,OAAAC,QAAAC,gCAC9BD,QAAAC,QACiBL,EAAOC,IAAOK,KAAA,SAA3BC,GAIN,OAFAJ,EAAQK,2BAA6BC,EAAAA,uBAAuB,CAAA,EAAIN,GAEzD,CACLO,OAAQ,CAAA,EACRT,OAAQM,EACR,4DAT8BI,CAAA,EAUjC,SAAQC,GACP,GA3CoB,SAACA,GACzB,OAAgB,MAAhBA,EAAMF,MAAc,CA0CZG,CAAkBD,GACpB,MAAO,CACLX,OAAQ,CAAE,EACVS,OAAQI,gBA3CQC,EA2CsBH,GAzCtCG,EAAmBL,QAAU,IAAIM,OAAO,SAACC,EAAKL,GAMpD,OALAK,EAAIL,EAAMM,KAAKC,KAAK,MAAQ,CAC1BC,KAAMR,EAAMA,MAAMS,KAClBC,QAASV,EAAMA,MAAMU,SAGhBL,CACT,EARkC,CAAE,IA0CkBd,IA3CxD,IAA0BY,EA+CpB,MAAMH,CACR,GACF,CAAC,MAAAW,GAAAnB,OAAAA,QAAAoB,OAAAD,EACH,CAAA,CAAA"}
|
|
@@ -13,14 +13,12 @@ const schema = Schema({
|
|
|
13
13
|
password: string.min(2).error(PASSWORD_REQUIRED_MESSAGE),
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
type FormData = Type<typeof schema> & { unusedProperty: string };
|
|
17
|
-
|
|
18
16
|
interface Props {
|
|
19
|
-
onSubmit: (data:
|
|
17
|
+
onSubmit: (data: Type<typeof schema>) => void;
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
function TestComponent({ onSubmit }: Props) {
|
|
23
|
-
const { register, handleSubmit } = useForm
|
|
21
|
+
const { register, handleSubmit } = useForm({
|
|
24
22
|
resolver: computedTypesResolver(schema),
|
|
25
23
|
shouldUseNativeValidation: true,
|
|
26
24
|
});
|
|
@@ -15,16 +15,14 @@ const schema = Schema({
|
|
|
15
15
|
|
|
16
16
|
type FormData = Type<typeof schema> & { unusedProperty: string };
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
onSubmit
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function TestComponent({ onSubmit }: Props) {
|
|
18
|
+
function TestComponent({
|
|
19
|
+
onSubmit,
|
|
20
|
+
}: { onSubmit: (data: Type<typeof schema>) => void }) {
|
|
23
21
|
const {
|
|
24
22
|
register,
|
|
25
23
|
handleSubmit,
|
|
26
24
|
formState: { errors },
|
|
27
|
-
} = useForm
|
|
25
|
+
} = useForm({
|
|
28
26
|
resolver: computedTypesResolver(schema), // Useful to check TypeScript regressions
|
|
29
27
|
});
|
|
30
28
|
|
|
@@ -59,3 +57,29 @@ test("form's validation with computed-types and TypeScript's integration", async
|
|
|
59
57
|
expect(screen.getByText(/zipCode field is required/i)).toBeInTheDocument();
|
|
60
58
|
expect(handleSubmit).not.toHaveBeenCalled();
|
|
61
59
|
});
|
|
60
|
+
|
|
61
|
+
export function TestComponentManualType({
|
|
62
|
+
onSubmit,
|
|
63
|
+
}: {
|
|
64
|
+
onSubmit: (data: FormData) => void;
|
|
65
|
+
}) {
|
|
66
|
+
const {
|
|
67
|
+
register,
|
|
68
|
+
handleSubmit,
|
|
69
|
+
formState: { errors },
|
|
70
|
+
} = useForm<Type<typeof schema>, undefined, FormData>({
|
|
71
|
+
resolver: computedTypesResolver(schema), // Useful to check TypeScript regressions
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
76
|
+
<input {...register('username')} />
|
|
77
|
+
{errors.username && <span role="alert">{errors.username.message}</span>}
|
|
78
|
+
|
|
79
|
+
<input {...register('password')} />
|
|
80
|
+
{errors.password && <span role="alert">{errors.password.message}</span>}
|
|
81
|
+
|
|
82
|
+
<button type="submit">submit</button>
|
|
83
|
+
</form>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
@@ -26,7 +26,9 @@ describe('computedTypesResolver', () => {
|
|
|
26
26
|
const schemaWithCustomError = schema.transform(() => {
|
|
27
27
|
throw Error('custom error');
|
|
28
28
|
});
|
|
29
|
+
|
|
29
30
|
const promise = computedTypesResolver(schemaWithCustomError)(
|
|
31
|
+
// @ts-expect-error expect to throw
|
|
30
32
|
validData,
|
|
31
33
|
undefined,
|
|
32
34
|
{
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import type { Resolver } from '
|
|
2
|
+
import { Type, ValidationError } from 'computed-types';
|
|
3
|
+
import FunctionType from 'computed-types/lib/schema/FunctionType';
|
|
4
|
+
import type { FieldErrors, Resolver } from 'react-hook-form';
|
|
5
5
|
|
|
6
6
|
const isValidationError = (error: any): error is ValidationError =>
|
|
7
7
|
error.errors != null;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
function parseErrorSchema(computedTypesError: ValidationError) {
|
|
10
10
|
const parsedErrors: FieldErrors = {};
|
|
11
11
|
return (computedTypesError.errors || []).reduce((acc, error) => {
|
|
12
12
|
acc[error.path.join('.')] = {
|
|
@@ -16,10 +16,26 @@ const parseErrorSchema = (computedTypesError: ValidationError) => {
|
|
|
16
16
|
|
|
17
17
|
return acc;
|
|
18
18
|
}, parsedErrors);
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Creates a resolver for react-hook-form using computed-types schema validation
|
|
23
|
+
* @param {Schema} schema - The computed-types schema to validate against
|
|
24
|
+
* @returns {Resolver<Type<typeof schema>>} A resolver function compatible with react-hook-form
|
|
25
|
+
* @example
|
|
26
|
+
* const schema = Schema({
|
|
27
|
+
* name: string,
|
|
28
|
+
* age: number
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* useForm({
|
|
32
|
+
* resolver: computedTypesResolver(schema)
|
|
33
|
+
* });
|
|
34
|
+
*/
|
|
35
|
+
export function computedTypesResolver<Schema extends FunctionType<any, any>>(
|
|
36
|
+
schema: Schema,
|
|
37
|
+
): Resolver<Type<typeof schema>> {
|
|
38
|
+
return async (values, _, options) => {
|
|
23
39
|
try {
|
|
24
40
|
const data = await schema(values);
|
|
25
41
|
|
|
@@ -40,3 +56,4 @@ export const computedTypesResolver: Resolver =
|
|
|
40
56
|
throw error;
|
|
41
57
|
}
|
|
42
58
|
};
|
|
59
|
+
}
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { ParseOptions } from 'effect/SchemaAST';
|
|
3
|
+
import { FieldValues, Resolver } from 'react-hook-form';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a resolver for react-hook-form using Effect.ts schema validation
|
|
6
|
+
* @param {Schema.Schema<TFieldValues, I>} schema - The Effect.ts schema to validate against
|
|
7
|
+
* @param {ParseOptions} [schemaOptions] - Optional Effect.ts validation options
|
|
8
|
+
* @returns {Resolver<Schema.Schema.Type<typeof schema>>} A resolver function compatible with react-hook-form
|
|
9
|
+
* @example
|
|
10
|
+
* const schema = Schema.Struct({
|
|
11
|
+
* name: Schema.String,
|
|
12
|
+
* age: Schema.Number
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* useForm({
|
|
16
|
+
* resolver: effectTsResolver(schema)
|
|
17
|
+
* });
|
|
18
|
+
*/
|
|
19
|
+
export declare function effectTsResolver<TFieldValues extends FieldValues, I>(schema: Schema.Schema<TFieldValues, I>, schemaOptions?: ParseOptions): Resolver<Schema.Schema.Type<typeof schema>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect-ts.js","sources":["../src/effect-ts.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { Effect } from 'effect';\
|
|
1
|
+
{"version":3,"file":"effect-ts.js","sources":["../src/effect-ts.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { Effect, Schema } from 'effect';\nimport { ArrayFormatter, decodeUnknown } from 'effect/ParseResult';\nimport { ParseOptions } from 'effect/SchemaAST';\nimport {\n type FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\n\n/**\n * Creates a resolver for react-hook-form using Effect.ts schema validation\n * @param {Schema.Schema<TFieldValues, I>} schema - The Effect.ts schema to validate against\n * @param {ParseOptions} [schemaOptions] - Optional Effect.ts validation options\n * @returns {Resolver<Schema.Schema.Type<typeof schema>>} A resolver function compatible with react-hook-form\n * @example\n * const schema = Schema.Struct({\n * name: Schema.String,\n * age: Schema.Number\n * });\n *\n * useForm({\n * resolver: effectTsResolver(schema)\n * });\n */\nexport function effectTsResolver<TFieldValues extends FieldValues, I>(\n schema: Schema.Schema<TFieldValues, I>,\n schemaOptions: ParseOptions = { errors: 'all', onExcessProperty: 'ignore' },\n): Resolver<Schema.Schema.Type<typeof schema>> {\n return (values, _, options) => {\n return decodeUnknown(\n schema,\n schemaOptions,\n )(values).pipe(\n Effect.catchAll((parseIssue) =>\n Effect.flip(ArrayFormatter.formatIssue(parseIssue)),\n ),\n Effect.mapError((issues) => {\n const validateAllFieldCriteria =\n !options.shouldUseNativeValidation && options.criteriaMode === 'all';\n\n const errors = issues.reduce(\n (acc, error) => {\n const key = error.path.join('.');\n\n if (!acc[key]) {\n acc[key] = { message: error.message, type: error._tag };\n }\n\n if (validateAllFieldCriteria) {\n const types = acc[key].types;\n const messages = types && types[String(error._tag)];\n\n acc[key] = appendErrors(\n key,\n validateAllFieldCriteria,\n acc,\n error._tag,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n return acc;\n },\n {} as Record<string, FieldError>,\n );\n\n return toNestErrors(errors, options);\n }),\n Effect.tap(() =>\n Effect.sync(\n () =>\n options.shouldUseNativeValidation &&\n validateFieldsNatively({}, options),\n ),\n ),\n Effect.match({\n onFailure: (errors) => ({ errors, values: {} }),\n onSuccess: (result) => ({ errors: {}, values: result }),\n }),\n Effect.runPromise,\n );\n };\n}\n"],"names":["schema","schemaOptions","errors","onExcessProperty","values","_","options","decodeUnknown","pipe","Effect","catchAll","parseIssue","flip","ArrayFormatter","formatIssue","mapError","issues","validateAllFieldCriteria","shouldUseNativeValidation","criteriaMode","reduce","acc","error","key","path","join","message","type","_tag","types","messages","String","appendErrors","concat","toNestErrors","tap","sync","validateFieldsNatively","match","onFailure","onSuccess","result","runPromise"],"mappings":"+IA0BgB,SACdA,EACAC,GAEA,YAFAA,IAAAA,IAAAA,EAA8B,CAAEC,OAAQ,MAAOC,iBAAkB,WAE1D,SAACC,EAAQC,EAAGC,GACjB,OAAOC,EAAaA,cAClBP,EACAC,EAFKM,CAGLH,GAAQI,KACRC,EAAMA,OAACC,SAAS,SAACC,GACf,OAAAF,SAAOG,KAAKC,EAAAA,eAAeC,YAAYH,GAAY,GAErDF,EAAAA,OAAOM,SAAS,SAACC,GACf,IAAMC,GACHX,EAAQY,2BAAsD,QAAzBZ,EAAQa,aAE1CjB,EAASc,EAAOI,OACpB,SAACC,EAAKC,GACJ,IAAMC,EAAMD,EAAME,KAAKC,KAAK,KAM5B,GAJKJ,EAAIE,KACPF,EAAIE,GAAO,CAAEG,QAASJ,EAAMI,QAASC,KAAML,EAAMM,OAG/CX,EAA0B,CAC5B,IAAMY,EAAQR,EAAIE,GAAKM,MACjBC,EAAWD,GAASA,EAAME,OAAOT,EAAMM,OAE7CP,EAAIE,GAAOS,EAAYA,aACrBT,EACAN,EACAI,EACAC,EAAMM,KACNE,EACK,GAAgBG,OAAOH,EAAsBR,EAAMI,SACpDJ,EAAMI,QAEd,CAEA,OAAOL,CACT,EACA,CAAgC,GAGlC,OAAOa,eAAahC,EAAQI,EAC9B,GACAG,EAAAA,OAAO0B,IAAI,WAAA,OACT1B,EAAAA,OAAO2B,KACL,kBACE9B,EAAQY,2BACRmB,EAAsBA,uBAAC,GAAI/B,EAAQ,EACtC,GAEHG,EAAAA,OAAO6B,MAAM,CACXC,UAAW,SAACrC,GAAM,MAAM,CAAEA,OAAAA,EAAQE,OAAQ,GAAI,EAC9CoC,UAAW,SAACC,GAAY,MAAA,CAAEvC,OAAQ,CAAA,EAAIE,OAAQqC,EAAQ,IAExDhC,EAAAA,OAAOiC,WAEX,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{Effect as t}from"effect";import{decodeUnknown as o,ArrayFormatter as n}from"effect/ParseResult";import{appendErrors as a}from"react-hook-form";
|
|
1
|
+
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{Effect as t}from"effect";import{decodeUnknown as o,ArrayFormatter as n}from"effect/ParseResult";import{appendErrors as a}from"react-hook-form";function i(i,s){return void 0===s&&(s={errors:"all",onExcessProperty:"ignore"}),function(u,c,f){return o(i,s)(u).pipe(t.catchAll(function(r){return t.flip(n.formatIssue(r))}),t.mapError(function(e){var t=!f.shouldUseNativeValidation&&"all"===f.criteriaMode,o=e.reduce(function(r,e){var o=e.path.join(".");if(r[o]||(r[o]={message:e.message,type:e._tag}),t){var n=r[o].types,i=n&&n[String(e._tag)];r[o]=a(o,t,r,e._tag,i?[].concat(i,e.message):e.message)}return r},{});return r(o,f)}),t.tap(function(){return t.sync(function(){return f.shouldUseNativeValidation&&e({},f)})}),t.match({onFailure:function(r){return{errors:r,values:{}}},onSuccess:function(r){return{errors:{},values:r}}}),t.runPromise)}}export{i as effectTsResolver};
|
|
2
2
|
//# sourceMappingURL=effect-ts.module.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toNestErrors as e,validateFieldsNatively as r}from"@hookform/resolvers";import{Effect as o}from"effect";import{decodeUnknown as
|
|
1
|
+
import{toNestErrors as e,validateFieldsNatively as r}from"@hookform/resolvers";import{Effect as o}from"effect";import{decodeUnknown as t,ArrayFormatter as s}from"effect/ParseResult";import{appendErrors as a}from"react-hook-form";function i(i,n={errors:"all",onExcessProperty:"ignore"}){return(c,m,l)=>t(i,n)(c).pipe(o.catchAll(e=>o.flip(s.formatIssue(e))),o.mapError(r=>{const o=!l.shouldUseNativeValidation&&"all"===l.criteriaMode,t=r.reduce((e,r)=>{const t=r.path.join(".");if(e[t]||(e[t]={message:r.message,type:r._tag}),o){const s=e[t].types,i=s&&s[String(r._tag)];e[t]=a(t,o,e,r._tag,i?[].concat(i,r.message):r.message)}return e},{});return e(t,l)}),o.tap(()=>o.sync(()=>l.shouldUseNativeValidation&&r({},l))),o.match({onFailure:e=>({errors:e,values:{}}),onSuccess:e=>({errors:{},values:e})}),o.runPromise)}export{i as effectTsResolver};
|
|
2
2
|
//# sourceMappingURL=effect-ts.modern.mjs.map
|