v1.0 with SW PWA enabled
This commit is contained in:
2
frontend/node_modules/@hookform/resolvers/zod/dist/index.d.ts
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/zod/dist/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './zod';
|
||||
export * from './types';
|
||||
13
frontend/node_modules/@hookform/resolvers/zod/dist/types.d.ts
generated
vendored
Normal file
13
frontend/node_modules/@hookform/resolvers/zod/dist/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
|
||||
import { z } from 'zod';
|
||||
export type Resolver = <T extends z.Schema<any, any>>(schema: T, schemaOptions?: Partial<z.ParseParams>, factoryOptions?: {
|
||||
/**
|
||||
* @default async
|
||||
*/
|
||||
mode?: 'async' | 'sync';
|
||||
/**
|
||||
* Return the raw input values rather than the parsed values.
|
||||
* @default false
|
||||
*/
|
||||
raw?: boolean;
|
||||
}) => <TFieldValues extends FieldValues, TContext>(values: TFieldValues, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<ResolverResult<TFieldValues>>;
|
||||
2
frontend/node_modules/@hookform/resolvers/zod/dist/zod.d.ts
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/zod/dist/zod.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import type { Resolver } from './types';
|
||||
export declare const zodResolver: Resolver;
|
||||
2
frontend/node_modules/@hookform/resolvers/zod/dist/zod.js
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/zod/dist/zod.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
var r=require("@hookform/resolvers"),e=require("react-hook-form"),o=function(r,o){for(var n={};r.length;){var s=r[0],t=s.code,i=s.message,a=s.path.join(".");if(!n[a])if("unionErrors"in s){var u=s.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code}}else n[a]={message:i,type:t};if("unionErrors"in s&&s.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),o){var c=n[a].types,f=c&&c[s.code];n[a]=e.appendErrors(a,o,n,t,f?[].concat(f,s.message):s.message)}r.shift()}return n};exports.zodResolver=function(e,n,s){return void 0===s&&(s={}),function(t,i,a){try{return Promise.resolve(function(o,i){try{var u=Promise.resolve(e["sync"===s.mode?"parse":"parseAsync"](t,n)).then(function(e){return a.shouldUseNativeValidation&&r.validateFieldsNatively({},a),{errors:{},values:s.raw?t:e}})}catch(r){return i(r)}return u&&u.then?u.then(void 0,i):u}(0,function(e){if(function(r){return Array.isArray(null==r?void 0:r.errors)}(e))return{values:{},errors:r.toNestErrors(o(e.errors,!a.shouldUseNativeValidation&&"all"===a.criteriaMode),a)};throw e}))}catch(r){return Promise.reject(r)}}};
|
||||
//# sourceMappingURL=zod.js.map
|
||||
1
frontend/node_modules/@hookform/resolvers/zod/dist/zod.js.map
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/zod/dist/zod.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"zod.js","sources":["../src/zod.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError, FieldErrors, appendErrors } from 'react-hook-form';\nimport { ZodError, z } from 'zod';\nimport type { Resolver } from './types';\n\nconst isZodError = (error: any): error is ZodError =>\n Array.isArray(error?.errors);\n\nconst parseErrorSchema = (\n zodErrors: z.ZodIssue[],\n validateAllFieldCriteria: boolean,\n) => {\n const errors: Record<string, FieldError> = {};\n for (; zodErrors.length; ) {\n const error = zodErrors[0];\n const { code, message, path } = error;\n const _path = path.join('.');\n\n if (!errors[_path]) {\n if ('unionErrors' in error) {\n const unionError = error.unionErrors[0].errors[0];\n\n errors[_path] = {\n message: unionError.message,\n type: unionError.code,\n };\n } else {\n errors[_path] = { message, type: code };\n }\n }\n\n if ('unionErrors' in error) {\n error.unionErrors.forEach((unionError) =>\n unionError.errors.forEach((e) => zodErrors.push(e)),\n );\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[error.code];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n code,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n zodErrors.shift();\n }\n\n return errors;\n};\n\nexport const zodResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n async (values, _, options) => {\n try {\n const data = await schema[\n resolverOptions.mode === 'sync' ? 'parse' : 'parseAsync'\n ](values, schemaOptions);\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n errors: {} as FieldErrors,\n values: resolverOptions.raw ? values : data,\n };\n } catch (error: any) {\n if (isZodError(error)) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n error.errors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n throw error;\n }\n };\n"],"names":["parseErrorSchema","zodErrors","validateAllFieldCriteria","errors","length","error","code","message","_path","path","join","unionError","unionErrors","type","forEach","e","push","types","messages","appendErrors","concat","shift","schema","schemaOptions","resolverOptions","values","_","options","Promise","resolve","mode","then","data","shouldUseNativeValidation","validateFieldsNatively","raw","_catch","Array","isArray","isZodError","toNestErrors","criteriaMode","reject"],"mappings":"kEAQMA,EAAmB,SACvBC,EACAC,GAGA,IADA,IAAMC,EAAqC,CAAE,EACtCF,EAAUG,QAAU,CACzB,IAAMC,EAAQJ,EAAU,GAChBK,EAAwBD,EAAxBC,KAAMC,EAAkBF,EAAlBE,QACRC,EAD0BH,EAATI,KACJC,KAAK,KAExB,IAAKP,EAAOK,GACV,GAAI,gBAAiBH,EAAO,CAC1B,IAAMM,EAAaN,EAAMO,YAAY,GAAGT,OAAO,GAE/CA,EAAOK,GAAS,CACdD,QAASI,EAAWJ,QACpBM,KAAMF,EAAWL,KAErB,MACEH,EAAOK,GAAS,CAAED,QAAAA,EAASM,KAAMP,GAUrC,GANI,gBAAiBD,GACnBA,EAAMO,YAAYE,QAAQ,SAACH,GAAU,OACnCA,EAAWR,OAAOW,QAAQ,SAACC,GAAM,OAAAd,EAAUe,KAAKD,EAAE,EAAC,GAInDb,EAA0B,CAC5B,IAAMe,EAAQd,EAAOK,GAAOS,MACtBC,EAAWD,GAASA,EAAMZ,EAAMC,MAEtCH,EAAOK,GAASW,EAAAA,aACdX,EACAN,EACAC,EACAG,EACAY,EACK,GAAgBE,OAAOF,EAAsBb,EAAME,SACpDF,EAAME,QAEd,CAEAN,EAAUoB,OACZ,CAEA,OAAOlB,CACT,sBAGE,SAACmB,EAAQC,EAAeC,GACjBC,YADgC,IAAfD,IAAAA,EAAkB,CAAE,GACrCC,SAAAA,EAAQC,EAAGC,GAAW,IAAA,OAAAC,QAAAC,gCACvBD,QAAAC,QACiBP,EACQ,SAAzBE,EAAgBM,KAAkB,QAAU,cAC5CL,EAAQF,IAAcQ,KAFlBC,SAAAA,GAMN,OAFAL,EAAQM,2BAA6BC,yBAAuB,CAAA,EAAIP,GAEzD,CACLxB,OAAQ,CAAiB,EACzBsB,OAAQD,EAAgBW,IAAMV,EAASO,EACvC,4DAXuBI,CACvB,EAWH,SAAQ/B,GACP,GApEa,SAACA,GAClB,OAAAgC,MAAMC,QAAa,MAALjC,OAAK,EAALA,EAAOF,OAAO,CAmEpBoC,CAAWlC,GACb,MAAO,CACLoB,OAAQ,CAAA,EACRtB,OAAQqC,EAAYA,aAClBxC,EACEK,EAAMF,QACLwB,EAAQM,2BACkB,QAAzBN,EAAQc,cAEZd,IAKN,MAAMtB,CACR,GACF,CAAC,MAAAU,GAAA,OAAAa,QAAAc,OAAA3B,EAAA,CAAA,CAAA"}
|
||||
2
frontend/node_modules/@hookform/resolvers/zod/dist/zod.mjs
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/zod/dist/zod.mjs
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";import{appendErrors as o}from"react-hook-form";var n=function(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("unionErrors"in t){var u=t.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code}}else n[a]={message:i,type:s};if("unionErrors"in t&&t.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=o(a,e,n,s,f?[].concat(f,t.message):t.message)}r.shift()}return n},t=function(o,t,s){return void 0===s&&(s={}),function(i,a,u){try{return Promise.resolve(function(e,n){try{var a=Promise.resolve(o["sync"===s.mode?"parse":"parseAsync"](i,t)).then(function(e){return u.shouldUseNativeValidation&&r({},u),{errors:{},values:s.raw?i:e}})}catch(r){return n(r)}return a&&a.then?a.then(void 0,n):a}(0,function(r){if(function(r){return Array.isArray(null==r?void 0:r.errors)}(r))return{values:{},errors:e(n(r.errors,!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)};throw r}))}catch(r){return Promise.reject(r)}}};export{t as zodResolver};
|
||||
//# sourceMappingURL=zod.module.js.map
|
||||
2
frontend/node_modules/@hookform/resolvers/zod/dist/zod.modern.mjs
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/zod/dist/zod.modern.mjs
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import{validateFieldsNatively as r,toNestErrors as o}from"@hookform/resolvers";import{appendErrors as s}from"react-hook-form";const e=(r,o)=>{const e={};for(;r.length;){const a=r[0],{code:t,message:n,path:i}=a,c=i.join(".");if(!e[c])if("unionErrors"in a){const r=a.unionErrors[0].errors[0];e[c]={message:r.message,type:r.code}}else e[c]={message:n,type:t};if("unionErrors"in a&&a.unionErrors.forEach(o=>o.errors.forEach(o=>r.push(o))),o){const r=e[c].types,n=r&&r[a.code];e[c]=s(c,o,e,t,n?[].concat(n,a.message):a.message)}r.shift()}return e},a=(s,a,t={})=>async(n,i,c)=>{try{const o=await s["sync"===t.mode?"parse":"parseAsync"](n,a);return c.shouldUseNativeValidation&&r({},c),{errors:{},values:t.raw?n:o}}catch(r){if((r=>Array.isArray(null==r?void 0:r.errors))(r))return{values:{},errors:o(e(r.errors,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)};throw r}};export{a as zodResolver};
|
||||
//# sourceMappingURL=zod.modern.mjs.map
|
||||
1
frontend/node_modules/@hookform/resolvers/zod/dist/zod.modern.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/zod/dist/zod.modern.mjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"zod.modern.mjs","sources":["../src/zod.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError, FieldErrors, appendErrors } from 'react-hook-form';\nimport { ZodError, z } from 'zod';\nimport type { Resolver } from './types';\n\nconst isZodError = (error: any): error is ZodError =>\n Array.isArray(error?.errors);\n\nconst parseErrorSchema = (\n zodErrors: z.ZodIssue[],\n validateAllFieldCriteria: boolean,\n) => {\n const errors: Record<string, FieldError> = {};\n for (; zodErrors.length; ) {\n const error = zodErrors[0];\n const { code, message, path } = error;\n const _path = path.join('.');\n\n if (!errors[_path]) {\n if ('unionErrors' in error) {\n const unionError = error.unionErrors[0].errors[0];\n\n errors[_path] = {\n message: unionError.message,\n type: unionError.code,\n };\n } else {\n errors[_path] = { message, type: code };\n }\n }\n\n if ('unionErrors' in error) {\n error.unionErrors.forEach((unionError) =>\n unionError.errors.forEach((e) => zodErrors.push(e)),\n );\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[error.code];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n code,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n zodErrors.shift();\n }\n\n return errors;\n};\n\nexport const zodResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n async (values, _, options) => {\n try {\n const data = await schema[\n resolverOptions.mode === 'sync' ? 'parse' : 'parseAsync'\n ](values, schemaOptions);\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n errors: {} as FieldErrors,\n values: resolverOptions.raw ? values : data,\n };\n } catch (error: any) {\n if (isZodError(error)) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n error.errors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n throw error;\n }\n };\n"],"names":["parseErrorSchema","zodErrors","validateAllFieldCriteria","errors","length","error","code","message","path","_path","join","unionError","unionErrors","type","forEach","e","push","types","messages","appendErrors","concat","shift","zodResolver","schema","schemaOptions","resolverOptions","async","values","_","options","data","mode","shouldUseNativeValidation","validateFieldsNatively","raw","Array","isArray","isZodError","toNestErrors","criteriaMode"],"mappings":"8HAKA,MAGMA,EAAmBA,CACvBC,EACAC,KAEA,MAAMC,EAAqC,CAAA,EAC3C,KAAOF,EAAUG,QAAU,CACzB,MAAMC,EAAQJ,EAAU,IAClBK,KAAEA,EAAIC,QAAEA,EAAOC,KAAEA,GAASH,EAC1BI,EAAQD,EAAKE,KAAK,KAExB,IAAKP,EAAOM,GACV,GAAI,gBAAiBJ,EAAO,CAC1B,MAAMM,EAAaN,EAAMO,YAAY,GAAGT,OAAO,GAE/CA,EAAOM,GAAS,CACdF,QAASI,EAAWJ,QACpBM,KAAMF,EAAWL,KAErB,MACEH,EAAOM,GAAS,CAAEF,UAASM,KAAMP,GAUrC,GANI,gBAAiBD,GACnBA,EAAMO,YAAYE,QAASH,GACzBA,EAAWR,OAAOW,QAASC,GAAMd,EAAUe,KAAKD,KAIhDb,EAA0B,CAC5B,MAAMe,EAAQd,EAAOM,GAAOQ,MACtBC,EAAWD,GAASA,EAAMZ,EAAMC,MAEtCH,EAAOM,GAASU,EACdV,EACAP,EACAC,EACAG,EACAY,EACK,GAAgBE,OAAOF,EAAsBb,EAAME,SACpDF,EAAME,QAEd,CAEAN,EAAUoB,OACZ,CAEA,OAAOlB,GAGImB,EACXA,CAACC,EAAQC,EAAeC,EAAkB,KAC1CC,MAAOC,EAAQC,EAAGC,KAChB,IACE,MAAMC,QAAaP,EACQ,SAAzBE,EAAgBM,KAAkB,QAAU,cAC5CJ,EAAQH,GAIV,OAFAK,EAAQG,2BAA6BC,EAAuB,CAAE,EAAEJ,GAEzD,CACL1B,OAAQ,CAAA,EACRwB,OAAQF,EAAgBS,IAAMP,EAASG,EAE3C,CAAE,MAAOzB,GACP,GApEcA,IAClB8B,MAAMC,QAAQ/B,MAAAA,OAAAA,EAAAA,EAAOF,QAmEbkC,CAAWhC,GACb,MAAO,CACLsB,OAAQ,GACRxB,OAAQmC,EACNtC,EACEK,EAAMF,QACL0B,EAAQG,2BACkB,QAAzBH,EAAQU,cAEZV,IAKN,MAAMxB,CACR"}
|
||||
2
frontend/node_modules/@hookform/resolvers/zod/dist/zod.module.js
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/zod/dist/zod.module.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";import{appendErrors as o}from"react-hook-form";var n=function(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!n[a])if("unionErrors"in t){var u=t.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code}}else n[a]={message:i,type:s};if("unionErrors"in t&&t.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=o(a,e,n,s,f?[].concat(f,t.message):t.message)}r.shift()}return n},t=function(o,t,s){return void 0===s&&(s={}),function(i,a,u){try{return Promise.resolve(function(e,n){try{var a=Promise.resolve(o["sync"===s.mode?"parse":"parseAsync"](i,t)).then(function(e){return u.shouldUseNativeValidation&&r({},u),{errors:{},values:s.raw?i:e}})}catch(r){return n(r)}return a&&a.then?a.then(void 0,n):a}(0,function(r){if(function(r){return Array.isArray(null==r?void 0:r.errors)}(r))return{values:{},errors:e(n(r.errors,!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)};throw r}))}catch(r){return Promise.reject(r)}}};export{t as zodResolver};
|
||||
//# sourceMappingURL=zod.module.js.map
|
||||
1
frontend/node_modules/@hookform/resolvers/zod/dist/zod.module.js.map
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/zod/dist/zod.module.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"zod.module.js","sources":["../src/zod.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError, FieldErrors, appendErrors } from 'react-hook-form';\nimport { ZodError, z } from 'zod';\nimport type { Resolver } from './types';\n\nconst isZodError = (error: any): error is ZodError =>\n Array.isArray(error?.errors);\n\nconst parseErrorSchema = (\n zodErrors: z.ZodIssue[],\n validateAllFieldCriteria: boolean,\n) => {\n const errors: Record<string, FieldError> = {};\n for (; zodErrors.length; ) {\n const error = zodErrors[0];\n const { code, message, path } = error;\n const _path = path.join('.');\n\n if (!errors[_path]) {\n if ('unionErrors' in error) {\n const unionError = error.unionErrors[0].errors[0];\n\n errors[_path] = {\n message: unionError.message,\n type: unionError.code,\n };\n } else {\n errors[_path] = { message, type: code };\n }\n }\n\n if ('unionErrors' in error) {\n error.unionErrors.forEach((unionError) =>\n unionError.errors.forEach((e) => zodErrors.push(e)),\n );\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[error.code];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n code,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n zodErrors.shift();\n }\n\n return errors;\n};\n\nexport const zodResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n async (values, _, options) => {\n try {\n const data = await schema[\n resolverOptions.mode === 'sync' ? 'parse' : 'parseAsync'\n ](values, schemaOptions);\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n errors: {} as FieldErrors,\n values: resolverOptions.raw ? values : data,\n };\n } catch (error: any) {\n if (isZodError(error)) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n error.errors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n throw error;\n }\n };\n"],"names":["parseErrorSchema","zodErrors","validateAllFieldCriteria","errors","length","error","code","message","_path","path","join","unionError","unionErrors","type","forEach","e","push","types","messages","appendErrors","concat","shift","zodResolver","schema","schemaOptions","resolverOptions","values","_","options","Promise","resolve","mode","then","data","shouldUseNativeValidation","validateFieldsNatively","raw","_catch","Array","isArray","isZodError","toNestErrors","criteriaMode","reject"],"mappings":"8HAKA,IAGMA,EAAmB,SACvBC,EACAC,GAGA,IADA,IAAMC,EAAqC,CAAE,EACtCF,EAAUG,QAAU,CACzB,IAAMC,EAAQJ,EAAU,GAChBK,EAAwBD,EAAxBC,KAAMC,EAAkBF,EAAlBE,QACRC,EAD0BH,EAATI,KACJC,KAAK,KAExB,IAAKP,EAAOK,GACV,GAAI,gBAAiBH,EAAO,CAC1B,IAAMM,EAAaN,EAAMO,YAAY,GAAGT,OAAO,GAE/CA,EAAOK,GAAS,CACdD,QAASI,EAAWJ,QACpBM,KAAMF,EAAWL,KAErB,MACEH,EAAOK,GAAS,CAAED,QAAAA,EAASM,KAAMP,GAUrC,GANI,gBAAiBD,GACnBA,EAAMO,YAAYE,QAAQ,SAACH,GAAU,OACnCA,EAAWR,OAAOW,QAAQ,SAACC,GAAM,OAAAd,EAAUe,KAAKD,EAAE,EAAC,GAInDb,EAA0B,CAC5B,IAAMe,EAAQd,EAAOK,GAAOS,MACtBC,EAAWD,GAASA,EAAMZ,EAAMC,MAEtCH,EAAOK,GAASW,EACdX,EACAN,EACAC,EACAG,EACAY,EACK,GAAgBE,OAAOF,EAAsBb,EAAME,SACpDF,EAAME,QAEd,CAEAN,EAAUoB,OACZ,CAEA,OAAOlB,CACT,EAEamB,EACX,SAACC,EAAQC,EAAeC,GACjBC,YADgC,IAAfD,IAAAA,EAAkB,CAAE,GACrCC,SAAAA,EAAQC,EAAGC,GAAW,IAAA,OAAAC,QAAAC,gCACvBD,QAAAC,QACiBP,EACQ,SAAzBE,EAAgBM,KAAkB,QAAU,cAC5CL,EAAQF,IAAcQ,KAFlBC,SAAAA,GAMN,OAFAL,EAAQM,2BAA6BC,EAAuB,CAAA,EAAIP,GAEzD,CACLzB,OAAQ,CAAiB,EACzBuB,OAAQD,EAAgBW,IAAMV,EAASO,EACvC,4DAXuBI,CACvB,EAWH,SAAQhC,GACP,GApEa,SAACA,GAClB,OAAAiC,MAAMC,QAAa,MAALlC,OAAK,EAALA,EAAOF,OAAO,CAmEpBqC,CAAWnC,GACb,MAAO,CACLqB,OAAQ,CAAA,EACRvB,OAAQsC,EACNzC,EACEK,EAAMF,QACLyB,EAAQM,2BACkB,QAAzBN,EAAQc,cAEZd,IAKN,MAAMvB,CACR,GACF,CAAC,MAAAU,GAAA,OAAAc,QAAAc,OAAA5B,EAAA,CAAA,CAAA"}
|
||||
2
frontend/node_modules/@hookform/resolvers/zod/dist/zod.umd.js
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/zod/dist/zod.umd.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@hookform/resolvers"),require("react-hook-form")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","react-hook-form"],e):e((r||self).hookformResolversZod={},r.hookformResolvers,r.ReactHookForm)}(this,function(r,e,o){var n=function(r,e){for(var n={};r.length;){var s=r[0],t=s.code,i=s.message,a=s.path.join(".");if(!n[a])if("unionErrors"in s){var u=s.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code}}else n[a]={message:i,type:t};if("unionErrors"in s&&s.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var f=n[a].types,c=f&&f[s.code];n[a]=o.appendErrors(a,e,n,t,c?[].concat(c,s.message):s.message)}r.shift()}return n};r.zodResolver=function(r,o,s){return void 0===s&&(s={}),function(t,i,a){try{return Promise.resolve(function(n,i){try{var u=Promise.resolve(r["sync"===s.mode?"parse":"parseAsync"](t,o)).then(function(r){return a.shouldUseNativeValidation&&e.validateFieldsNatively({},a),{errors:{},values:s.raw?t:r}})}catch(r){return i(r)}return u&&u.then?u.then(void 0,i):u}(0,function(r){if(function(r){return Array.isArray(null==r?void 0:r.errors)}(r))return{values:{},errors:e.toNestErrors(n(r.errors,!a.shouldUseNativeValidation&&"all"===a.criteriaMode),a)};throw r}))}catch(r){return Promise.reject(r)}}}});
|
||||
//# sourceMappingURL=zod.umd.js.map
|
||||
1
frontend/node_modules/@hookform/resolvers/zod/dist/zod.umd.js.map
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/zod/dist/zod.umd.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"zod.umd.js","sources":["../src/zod.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { FieldError, FieldErrors, appendErrors } from 'react-hook-form';\nimport { ZodError, z } from 'zod';\nimport type { Resolver } from './types';\n\nconst isZodError = (error: any): error is ZodError =>\n Array.isArray(error?.errors);\n\nconst parseErrorSchema = (\n zodErrors: z.ZodIssue[],\n validateAllFieldCriteria: boolean,\n) => {\n const errors: Record<string, FieldError> = {};\n for (; zodErrors.length; ) {\n const error = zodErrors[0];\n const { code, message, path } = error;\n const _path = path.join('.');\n\n if (!errors[_path]) {\n if ('unionErrors' in error) {\n const unionError = error.unionErrors[0].errors[0];\n\n errors[_path] = {\n message: unionError.message,\n type: unionError.code,\n };\n } else {\n errors[_path] = { message, type: code };\n }\n }\n\n if ('unionErrors' in error) {\n error.unionErrors.forEach((unionError) =>\n unionError.errors.forEach((e) => zodErrors.push(e)),\n );\n }\n\n if (validateAllFieldCriteria) {\n const types = errors[_path].types;\n const messages = types && types[error.code];\n\n errors[_path] = appendErrors(\n _path,\n validateAllFieldCriteria,\n errors,\n code,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n zodErrors.shift();\n }\n\n return errors;\n};\n\nexport const zodResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n async (values, _, options) => {\n try {\n const data = await schema[\n resolverOptions.mode === 'sync' ? 'parse' : 'parseAsync'\n ](values, schemaOptions);\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n errors: {} as FieldErrors,\n values: resolverOptions.raw ? values : data,\n };\n } catch (error: any) {\n if (isZodError(error)) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n error.errors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n throw error;\n }\n };\n"],"names":["parseErrorSchema","zodErrors","validateAllFieldCriteria","errors","length","error","code","message","_path","path","join","unionError","unionErrors","type","forEach","e","push","types","messages","appendErrors","concat","shift","schema","schemaOptions","resolverOptions","values","_","options","Promise","resolve","mode","then","data","shouldUseNativeValidation","validateFieldsNatively","raw","_catch","Array","isArray","isZodError","toNestErrors","criteriaMode","reject"],"mappings":"wXAKA,IAGMA,EAAmB,SACvBC,EACAC,GAGA,IADA,IAAMC,EAAqC,CAAE,EACtCF,EAAUG,QAAU,CACzB,IAAMC,EAAQJ,EAAU,GAChBK,EAAwBD,EAAxBC,KAAMC,EAAkBF,EAAlBE,QACRC,EAD0BH,EAATI,KACJC,KAAK,KAExB,IAAKP,EAAOK,GACV,GAAI,gBAAiBH,EAAO,CAC1B,IAAMM,EAAaN,EAAMO,YAAY,GAAGT,OAAO,GAE/CA,EAAOK,GAAS,CACdD,QAASI,EAAWJ,QACpBM,KAAMF,EAAWL,KAErB,MACEH,EAAOK,GAAS,CAAED,QAAAA,EAASM,KAAMP,GAUrC,GANI,gBAAiBD,GACnBA,EAAMO,YAAYE,QAAQ,SAACH,GAAU,OACnCA,EAAWR,OAAOW,QAAQ,SAACC,GAAM,OAAAd,EAAUe,KAAKD,EAAE,EAAC,GAInDb,EAA0B,CAC5B,IAAMe,EAAQd,EAAOK,GAAOS,MACtBC,EAAWD,GAASA,EAAMZ,EAAMC,MAEtCH,EAAOK,GAASW,EAAAA,aACdX,EACAN,EACAC,EACAG,EACAY,EACK,GAAgBE,OAAOF,EAAsBb,EAAME,SACpDF,EAAME,QAEd,CAEAN,EAAUoB,OACZ,CAEA,OAAOlB,CACT,gBAGE,SAACmB,EAAQC,EAAeC,GACjBC,YADgC,IAAfD,IAAAA,EAAkB,CAAE,GACrCC,SAAAA,EAAQC,EAAGC,GAAW,IAAA,OAAAC,QAAAC,gCACvBD,QAAAC,QACiBP,EACQ,SAAzBE,EAAgBM,KAAkB,QAAU,cAC5CL,EAAQF,IAAcQ,KAFlBC,SAAAA,GAMN,OAFAL,EAAQM,2BAA6BC,yBAAuB,CAAA,EAAIP,GAEzD,CACLxB,OAAQ,CAAiB,EACzBsB,OAAQD,EAAgBW,IAAMV,EAASO,EACvC,4DAXuBI,CACvB,EAWH,SAAQ/B,GACP,GApEa,SAACA,GAClB,OAAAgC,MAAMC,QAAa,MAALjC,OAAK,EAALA,EAAOF,OAAO,CAmEpBoC,CAAWlC,GACb,MAAO,CACLoB,OAAQ,CAAA,EACRtB,OAAQqC,EAAYA,aAClBxC,EACEK,EAAMF,QACLwB,EAAQM,2BACkB,QAAzBN,EAAQc,cAEZd,IAKN,MAAMtB,CACR,GACF,CAAC,MAAAU,GAAA,OAAAa,QAAAc,OAAA3B,EAAA,CAAA,CAAA"}
|
||||
17
frontend/node_modules/@hookform/resolvers/zod/package.json
generated
vendored
Normal file
17
frontend/node_modules/@hookform/resolvers/zod/package.json
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@hookform/resolvers/zod",
|
||||
"amdName": "hookformResolversZod",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "React Hook Form validation resolver: zod",
|
||||
"main": "dist/zod.js",
|
||||
"module": "dist/zod.module.js",
|
||||
"umd:main": "dist/zod.umd.js",
|
||||
"source": "src/index.ts",
|
||||
"types": "dist/index.d.ts",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react-hook-form": "^7.0.0",
|
||||
"@hookform/resolvers": "^2.0.0"
|
||||
}
|
||||
}
|
||||
81
frontend/node_modules/@hookform/resolvers/zod/src/__tests__/Form-native-validation.tsx
generated
vendored
Normal file
81
frontend/node_modules/@hookform/resolvers/zod/src/__tests__/Form-native-validation.tsx
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import user from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { z } from 'zod';
|
||||
import { zodResolver } from '..';
|
||||
|
||||
const USERNAME_REQUIRED_MESSAGE = 'username field is required';
|
||||
const PASSWORD_REQUIRED_MESSAGE = 'password field is required';
|
||||
|
||||
const schema = z.object({
|
||||
username: z.string().nonempty({ message: USERNAME_REQUIRED_MESSAGE }),
|
||||
password: z.string().nonempty({ message: PASSWORD_REQUIRED_MESSAGE }),
|
||||
});
|
||||
|
||||
type FormData = z.infer<typeof schema>;
|
||||
|
||||
interface Props {
|
||||
onSubmit: (data: FormData) => void;
|
||||
}
|
||||
|
||||
function TestComponent({ onSubmit }: Props) {
|
||||
const { register, handleSubmit } = useForm<FormData>({
|
||||
resolver: zodResolver(schema),
|
||||
shouldUseNativeValidation: true,
|
||||
});
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<input {...register('username')} placeholder="username" />
|
||||
|
||||
<input {...register('password')} placeholder="password" />
|
||||
|
||||
<button type="submit">submit</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
test("form's native validation with Zod", async () => {
|
||||
const handleSubmit = vi.fn();
|
||||
render(<TestComponent onSubmit={handleSubmit} />);
|
||||
|
||||
// username
|
||||
let usernameField = screen.getByPlaceholderText(
|
||||
/username/i,
|
||||
) as HTMLInputElement;
|
||||
expect(usernameField.validity.valid).toBe(true);
|
||||
expect(usernameField.validationMessage).toBe('');
|
||||
|
||||
// password
|
||||
let passwordField = screen.getByPlaceholderText(
|
||||
/password/i,
|
||||
) as HTMLInputElement;
|
||||
expect(passwordField.validity.valid).toBe(true);
|
||||
expect(passwordField.validationMessage).toBe('');
|
||||
|
||||
await user.click(screen.getByText(/submit/i));
|
||||
|
||||
// username
|
||||
usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement;
|
||||
expect(usernameField.validity.valid).toBe(false);
|
||||
expect(usernameField.validationMessage).toBe(USERNAME_REQUIRED_MESSAGE);
|
||||
|
||||
// password
|
||||
passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement;
|
||||
expect(passwordField.validity.valid).toBe(false);
|
||||
expect(passwordField.validationMessage).toBe(PASSWORD_REQUIRED_MESSAGE);
|
||||
|
||||
await user.type(screen.getByPlaceholderText(/username/i), 'joe');
|
||||
await user.type(screen.getByPlaceholderText(/password/i), 'password');
|
||||
|
||||
// username
|
||||
usernameField = screen.getByPlaceholderText(/username/i) as HTMLInputElement;
|
||||
expect(usernameField.validity.valid).toBe(true);
|
||||
expect(usernameField.validationMessage).toBe('');
|
||||
|
||||
// password
|
||||
passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement;
|
||||
expect(passwordField.validity.valid).toBe(true);
|
||||
expect(passwordField.validationMessage).toBe('');
|
||||
});
|
||||
52
frontend/node_modules/@hookform/resolvers/zod/src/__tests__/Form.tsx
generated
vendored
Normal file
52
frontend/node_modules/@hookform/resolvers/zod/src/__tests__/Form.tsx
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import user from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { z } from 'zod';
|
||||
import { zodResolver } from '..';
|
||||
|
||||
const schema = z.object({
|
||||
username: z.string().nonempty({ message: 'username field is required' }),
|
||||
password: z.string().nonempty({ message: 'password field is required' }),
|
||||
});
|
||||
|
||||
type FormData = z.infer<typeof schema> & { unusedProperty: string };
|
||||
|
||||
interface Props {
|
||||
onSubmit: (data: FormData) => void;
|
||||
}
|
||||
|
||||
function TestComponent({ onSubmit }: Props) {
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm<FormData>({
|
||||
resolver: zodResolver(schema), // Useful to check TypeScript regressions
|
||||
});
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<input {...register('username')} />
|
||||
{errors.username && <span role="alert">{errors.username.message}</span>}
|
||||
|
||||
<input {...register('password')} />
|
||||
{errors.password && <span role="alert">{errors.password.message}</span>}
|
||||
|
||||
<button type="submit">submit</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
test("form's validation with Zod and TypeScript's integration", async () => {
|
||||
const handleSubmit = vi.fn();
|
||||
render(<TestComponent onSubmit={handleSubmit} />);
|
||||
|
||||
expect(screen.queryAllByRole('alert')).toHaveLength(0);
|
||||
|
||||
await user.click(screen.getByText(/submit/i));
|
||||
|
||||
expect(screen.getByText(/username field is required/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/password field is required/i)).toBeInTheDocument();
|
||||
expect(handleSubmit).not.toHaveBeenCalled();
|
||||
});
|
||||
88
frontend/node_modules/@hookform/resolvers/zod/src/__tests__/__fixtures__/data.ts
generated
vendored
Normal file
88
frontend/node_modules/@hookform/resolvers/zod/src/__tests__/__fixtures__/data.ts
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
import { Field, InternalFieldName } from 'react-hook-form';
|
||||
import { z } from 'zod';
|
||||
|
||||
export const schema = z
|
||||
.object({
|
||||
username: z.string().regex(/^\w+$/).min(3).max(30),
|
||||
password: z
|
||||
.string()
|
||||
.regex(new RegExp('.*[A-Z].*'), 'One uppercase character')
|
||||
.regex(new RegExp('.*[a-z].*'), 'One lowercase character')
|
||||
.regex(new RegExp('.*\\d.*'), 'One number')
|
||||
.regex(
|
||||
new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'),
|
||||
'One special character',
|
||||
)
|
||||
.min(8, 'Must be at least 8 characters in length'),
|
||||
repeatPassword: z.string(),
|
||||
accessToken: z.union([z.string(), z.number()]),
|
||||
birthYear: z.number().min(1900).max(2013).optional(),
|
||||
email: z.string().email().optional(),
|
||||
tags: z.array(z.string()),
|
||||
enabled: z.boolean(),
|
||||
url: z.string().url('Custom error url').or(z.literal('')),
|
||||
like: z
|
||||
.array(
|
||||
z.object({
|
||||
id: z.number(),
|
||||
name: z.string().length(4),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
dateStr: z
|
||||
.string()
|
||||
.transform((value) => new Date(value))
|
||||
.refine((value) => !isNaN(value.getTime()), {
|
||||
message: 'Invalid date',
|
||||
}),
|
||||
})
|
||||
.refine((obj) => obj.password === obj.repeatPassword, {
|
||||
message: 'Passwords do not match',
|
||||
path: ['confirm'],
|
||||
});
|
||||
|
||||
export const validData: z.input<typeof schema> = {
|
||||
username: 'Doe',
|
||||
password: 'Password123_',
|
||||
repeatPassword: 'Password123_',
|
||||
birthYear: 2000,
|
||||
email: 'john@doe.com',
|
||||
tags: ['tag1', 'tag2'],
|
||||
enabled: true,
|
||||
accessToken: 'accessToken',
|
||||
url: 'https://react-hook-form.com/',
|
||||
like: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'name',
|
||||
},
|
||||
],
|
||||
dateStr: '2020-01-01',
|
||||
};
|
||||
|
||||
export const invalidData = {
|
||||
password: '___',
|
||||
email: '',
|
||||
birthYear: 'birthYear',
|
||||
like: [{ id: 'z' }],
|
||||
url: 'abc',
|
||||
};
|
||||
|
||||
export const fields: Record<InternalFieldName, Field['_f']> = {
|
||||
username: {
|
||||
ref: { name: 'username' },
|
||||
name: 'username',
|
||||
},
|
||||
password: {
|
||||
ref: { name: 'password' },
|
||||
name: 'password',
|
||||
},
|
||||
email: {
|
||||
ref: { name: 'email' },
|
||||
name: 'email',
|
||||
},
|
||||
birthday: {
|
||||
ref: { name: 'birthday' },
|
||||
name: 'birthday',
|
||||
},
|
||||
};
|
||||
430
frontend/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod.ts.snap
generated
vendored
Normal file
430
frontend/node_modules/@hookform/resolvers/zod/src/__tests__/__snapshots__/zod.ts.snap
generated
vendored
Normal file
@ -0,0 +1,430 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`zodResolver > should return a single error from zodResolver when validation fails 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"accessToken": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"birthYear": {
|
||||
"message": "Expected number, received string",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"dateStr": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"email": {
|
||||
"message": "Invalid email",
|
||||
"ref": {
|
||||
"name": "email",
|
||||
},
|
||||
"type": "invalid_string",
|
||||
},
|
||||
"enabled": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"like": [
|
||||
{
|
||||
"id": {
|
||||
"message": "Expected number, received string",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"name": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
},
|
||||
],
|
||||
"password": {
|
||||
"message": "One uppercase character",
|
||||
"ref": {
|
||||
"name": "password",
|
||||
},
|
||||
"type": "invalid_string",
|
||||
},
|
||||
"repeatPassword": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"tags": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"url": {
|
||||
"message": "Custom error url",
|
||||
"ref": undefined,
|
||||
"type": "invalid_string",
|
||||
},
|
||||
"username": {
|
||||
"message": "Required",
|
||||
"ref": {
|
||||
"name": "username",
|
||||
},
|
||||
"type": "invalid_type",
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`zodResolver > should return a single error from zodResolver with \`mode: sync\` when validation fails 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"accessToken": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"birthYear": {
|
||||
"message": "Expected number, received string",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"dateStr": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"email": {
|
||||
"message": "Invalid email",
|
||||
"ref": {
|
||||
"name": "email",
|
||||
},
|
||||
"type": "invalid_string",
|
||||
},
|
||||
"enabled": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"like": [
|
||||
{
|
||||
"id": {
|
||||
"message": "Expected number, received string",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"name": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
},
|
||||
],
|
||||
"password": {
|
||||
"message": "One uppercase character",
|
||||
"ref": {
|
||||
"name": "password",
|
||||
},
|
||||
"type": "invalid_string",
|
||||
},
|
||||
"repeatPassword": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"tags": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
},
|
||||
"url": {
|
||||
"message": "Custom error url",
|
||||
"ref": undefined,
|
||||
"type": "invalid_string",
|
||||
},
|
||||
"username": {
|
||||
"message": "Required",
|
||||
"ref": {
|
||||
"name": "username",
|
||||
},
|
||||
"type": "invalid_type",
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`zodResolver > should return all the errors from zodResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"accessToken": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": [
|
||||
"Required",
|
||||
"Required",
|
||||
],
|
||||
"invalid_union": "Invalid input",
|
||||
},
|
||||
},
|
||||
"birthYear": {
|
||||
"message": "Expected number, received string",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Expected number, received string",
|
||||
},
|
||||
},
|
||||
"dateStr": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Required",
|
||||
},
|
||||
},
|
||||
"email": {
|
||||
"message": "Invalid email",
|
||||
"ref": {
|
||||
"name": "email",
|
||||
},
|
||||
"type": "invalid_string",
|
||||
"types": {
|
||||
"invalid_string": "Invalid email",
|
||||
},
|
||||
},
|
||||
"enabled": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Required",
|
||||
},
|
||||
},
|
||||
"like": [
|
||||
{
|
||||
"id": {
|
||||
"message": "Expected number, received string",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Expected number, received string",
|
||||
},
|
||||
},
|
||||
"name": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Required",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"password": {
|
||||
"message": "One uppercase character",
|
||||
"ref": {
|
||||
"name": "password",
|
||||
},
|
||||
"type": "invalid_string",
|
||||
"types": {
|
||||
"invalid_string": [
|
||||
"One uppercase character",
|
||||
"One lowercase character",
|
||||
"One number",
|
||||
],
|
||||
"too_small": "Must be at least 8 characters in length",
|
||||
},
|
||||
},
|
||||
"repeatPassword": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Required",
|
||||
},
|
||||
},
|
||||
"tags": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Required",
|
||||
},
|
||||
},
|
||||
"url": {
|
||||
"message": "Custom error url",
|
||||
"ref": undefined,
|
||||
"type": "invalid_string",
|
||||
"types": {
|
||||
"invalid_string": "Custom error url",
|
||||
},
|
||||
},
|
||||
"username": {
|
||||
"message": "Required",
|
||||
"ref": {
|
||||
"name": "username",
|
||||
},
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Required",
|
||||
},
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`zodResolver > should return all the errors from zodResolver when validation fails with \`validateAllFieldCriteria\` set to true and \`mode: sync\` 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"accessToken": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": [
|
||||
"Required",
|
||||
"Required",
|
||||
],
|
||||
"invalid_union": "Invalid input",
|
||||
},
|
||||
},
|
||||
"birthYear": {
|
||||
"message": "Expected number, received string",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Expected number, received string",
|
||||
},
|
||||
},
|
||||
"dateStr": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Required",
|
||||
},
|
||||
},
|
||||
"email": {
|
||||
"message": "Invalid email",
|
||||
"ref": {
|
||||
"name": "email",
|
||||
},
|
||||
"type": "invalid_string",
|
||||
"types": {
|
||||
"invalid_string": "Invalid email",
|
||||
},
|
||||
},
|
||||
"enabled": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Required",
|
||||
},
|
||||
},
|
||||
"like": [
|
||||
{
|
||||
"id": {
|
||||
"message": "Expected number, received string",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Expected number, received string",
|
||||
},
|
||||
},
|
||||
"name": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Required",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"password": {
|
||||
"message": "One uppercase character",
|
||||
"ref": {
|
||||
"name": "password",
|
||||
},
|
||||
"type": "invalid_string",
|
||||
"types": {
|
||||
"invalid_string": [
|
||||
"One uppercase character",
|
||||
"One lowercase character",
|
||||
"One number",
|
||||
],
|
||||
"too_small": "Must be at least 8 characters in length",
|
||||
},
|
||||
},
|
||||
"repeatPassword": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Required",
|
||||
},
|
||||
},
|
||||
"tags": {
|
||||
"message": "Required",
|
||||
"ref": undefined,
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Required",
|
||||
},
|
||||
},
|
||||
"url": {
|
||||
"message": "Custom error url",
|
||||
"ref": undefined,
|
||||
"type": "invalid_string",
|
||||
"types": {
|
||||
"invalid_string": "Custom error url",
|
||||
},
|
||||
},
|
||||
"username": {
|
||||
"message": "Required",
|
||||
"ref": {
|
||||
"name": "username",
|
||||
},
|
||||
"type": "invalid_type",
|
||||
"types": {
|
||||
"invalid_type": "Required",
|
||||
},
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`zodResolver > should return parsed values from zodResolver with \`mode: sync\` when validation pass 1`] = `
|
||||
{
|
||||
"errors": {},
|
||||
"values": {
|
||||
"accessToken": "accessToken",
|
||||
"birthYear": 2000,
|
||||
"dateStr": 2020-01-01T00:00:00.000Z,
|
||||
"email": "john@doe.com",
|
||||
"enabled": true,
|
||||
"like": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "name",
|
||||
},
|
||||
],
|
||||
"password": "Password123_",
|
||||
"repeatPassword": "Password123_",
|
||||
"tags": [
|
||||
"tag1",
|
||||
"tag2",
|
||||
],
|
||||
"url": "https://react-hook-form.com/",
|
||||
"username": "Doe",
|
||||
},
|
||||
}
|
||||
`;
|
||||
92
frontend/node_modules/@hookform/resolvers/zod/src/__tests__/zod.ts
generated
vendored
Normal file
92
frontend/node_modules/@hookform/resolvers/zod/src/__tests__/zod.ts
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
import { zodResolver } from '..';
|
||||
import { fields, invalidData, schema, validData } from './__fixtures__/data';
|
||||
|
||||
const shouldUseNativeValidation = false;
|
||||
|
||||
describe('zodResolver', () => {
|
||||
it('should return values from zodResolver when validation pass & raw=true', async () => {
|
||||
const parseAsyncSpy = vi.spyOn(schema, 'parseAsync');
|
||||
|
||||
const result = await zodResolver(schema, undefined, {
|
||||
raw: true,
|
||||
})(validData, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(parseAsyncSpy).toHaveBeenCalledTimes(1);
|
||||
expect(result).toEqual({ errors: {}, values: validData });
|
||||
});
|
||||
|
||||
it('should return parsed values from zodResolver with `mode: sync` when validation pass', async () => {
|
||||
const parseSpy = vi.spyOn(schema, 'parse');
|
||||
const parseAsyncSpy = vi.spyOn(schema, 'parseAsync');
|
||||
|
||||
const result = await zodResolver(schema, undefined, {
|
||||
mode: 'sync',
|
||||
})(validData, undefined, { fields, shouldUseNativeValidation });
|
||||
|
||||
expect(parseSpy).toHaveBeenCalledTimes(1);
|
||||
expect(parseAsyncSpy).not.toHaveBeenCalled();
|
||||
expect(result.errors).toEqual({});
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return a single error from zodResolver when validation fails', async () => {
|
||||
const result = await zodResolver(schema)(invalidData, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return a single error from zodResolver with `mode: sync` when validation fails', async () => {
|
||||
const parseSpy = vi.spyOn(schema, 'parse');
|
||||
const parseAsyncSpy = vi.spyOn(schema, 'parseAsync');
|
||||
|
||||
const result = await zodResolver(schema, undefined, {
|
||||
mode: 'sync',
|
||||
})(invalidData, undefined, { fields, shouldUseNativeValidation });
|
||||
|
||||
expect(parseSpy).toHaveBeenCalledTimes(1);
|
||||
expect(parseAsyncSpy).not.toHaveBeenCalled();
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return all the errors from zodResolver when validation fails with `validateAllFieldCriteria` set to true', async () => {
|
||||
const result = await zodResolver(schema)(invalidData, undefined, {
|
||||
fields,
|
||||
criteriaMode: 'all',
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return all the errors from zodResolver when validation fails with `validateAllFieldCriteria` set to true and `mode: sync`', async () => {
|
||||
const result = await zodResolver(schema, undefined, { mode: 'sync' })(
|
||||
invalidData,
|
||||
undefined,
|
||||
{
|
||||
fields,
|
||||
criteriaMode: 'all',
|
||||
shouldUseNativeValidation,
|
||||
},
|
||||
);
|
||||
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should throw any error unrelated to Zod', async () => {
|
||||
const schemaWithCustomError = schema.refine(() => {
|
||||
throw Error('custom error');
|
||||
});
|
||||
const promise = zodResolver(schemaWithCustomError)(validData, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
await expect(promise).rejects.toThrow('custom error');
|
||||
});
|
||||
});
|
||||
2
frontend/node_modules/@hookform/resolvers/zod/src/index.ts
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/zod/src/index.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './zod';
|
||||
export * from './types';
|
||||
22
frontend/node_modules/@hookform/resolvers/zod/src/types.ts
generated
vendored
Normal file
22
frontend/node_modules/@hookform/resolvers/zod/src/types.ts
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
import { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
|
||||
import { z } from 'zod';
|
||||
|
||||
export type Resolver = <T extends z.Schema<any, any>>(
|
||||
schema: T,
|
||||
schemaOptions?: Partial<z.ParseParams>,
|
||||
factoryOptions?: {
|
||||
/**
|
||||
* @default async
|
||||
*/
|
||||
mode?: 'async' | 'sync';
|
||||
/**
|
||||
* Return the raw input values rather than the parsed values.
|
||||
* @default false
|
||||
*/
|
||||
raw?: boolean;
|
||||
},
|
||||
) => <TFieldValues extends FieldValues, TContext>(
|
||||
values: TFieldValues,
|
||||
context: TContext | undefined,
|
||||
options: ResolverOptions<TFieldValues>,
|
||||
) => Promise<ResolverResult<TFieldValues>>;
|
||||
90
frontend/node_modules/@hookform/resolvers/zod/src/zod.ts
generated
vendored
Normal file
90
frontend/node_modules/@hookform/resolvers/zod/src/zod.ts
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';
|
||||
import { FieldError, FieldErrors, appendErrors } from 'react-hook-form';
|
||||
import { ZodError, z } from 'zod';
|
||||
import type { Resolver } from './types';
|
||||
|
||||
const isZodError = (error: any): error is ZodError =>
|
||||
Array.isArray(error?.errors);
|
||||
|
||||
const parseErrorSchema = (
|
||||
zodErrors: z.ZodIssue[],
|
||||
validateAllFieldCriteria: boolean,
|
||||
) => {
|
||||
const errors: Record<string, FieldError> = {};
|
||||
for (; zodErrors.length; ) {
|
||||
const error = zodErrors[0];
|
||||
const { code, message, path } = error;
|
||||
const _path = path.join('.');
|
||||
|
||||
if (!errors[_path]) {
|
||||
if ('unionErrors' in error) {
|
||||
const unionError = error.unionErrors[0].errors[0];
|
||||
|
||||
errors[_path] = {
|
||||
message: unionError.message,
|
||||
type: unionError.code,
|
||||
};
|
||||
} else {
|
||||
errors[_path] = { message, type: code };
|
||||
}
|
||||
}
|
||||
|
||||
if ('unionErrors' in error) {
|
||||
error.unionErrors.forEach((unionError) =>
|
||||
unionError.errors.forEach((e) => zodErrors.push(e)),
|
||||
);
|
||||
}
|
||||
|
||||
if (validateAllFieldCriteria) {
|
||||
const types = errors[_path].types;
|
||||
const messages = types && types[error.code];
|
||||
|
||||
errors[_path] = appendErrors(
|
||||
_path,
|
||||
validateAllFieldCriteria,
|
||||
errors,
|
||||
code,
|
||||
messages
|
||||
? ([] as string[]).concat(messages as string[], error.message)
|
||||
: error.message,
|
||||
) as FieldError;
|
||||
}
|
||||
|
||||
zodErrors.shift();
|
||||
}
|
||||
|
||||
return errors;
|
||||
};
|
||||
|
||||
export const zodResolver: Resolver =
|
||||
(schema, schemaOptions, resolverOptions = {}) =>
|
||||
async (values, _, options) => {
|
||||
try {
|
||||
const data = await schema[
|
||||
resolverOptions.mode === 'sync' ? 'parse' : 'parseAsync'
|
||||
](values, schemaOptions);
|
||||
|
||||
options.shouldUseNativeValidation && validateFieldsNatively({}, options);
|
||||
|
||||
return {
|
||||
errors: {} as FieldErrors,
|
||||
values: resolverOptions.raw ? values : data,
|
||||
};
|
||||
} catch (error: any) {
|
||||
if (isZodError(error)) {
|
||||
return {
|
||||
values: {},
|
||||
errors: toNestErrors(
|
||||
parseErrorSchema(
|
||||
error.errors,
|
||||
!options.shouldUseNativeValidation &&
|
||||
options.criteriaMode === 'all',
|
||||
),
|
||||
options,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user