v1.0 with SW PWA enabled
This commit is contained in:
1
frontend/node_modules/@hookform/resolvers/yup/dist/index.d.ts
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/yup/dist/index.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export * from './yup';
|
||||
13
frontend/node_modules/@hookform/resolvers/yup/dist/yup.d.ts
generated
vendored
Normal file
13
frontend/node_modules/@hookform/resolvers/yup/dist/yup.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import { FieldValues, Resolver } from 'react-hook-form';
|
||||
import * as Yup from 'yup';
|
||||
export declare function yupResolver<TFieldValues extends FieldValues>(schema: Yup.ObjectSchema<TFieldValues> | ReturnType<typeof Yup.lazy<Yup.ObjectSchema<TFieldValues>>>, schemaOptions?: Parameters<(typeof schema)['validate']>[1], resolverOptions?: {
|
||||
/**
|
||||
* @default async
|
||||
*/
|
||||
mode?: 'async' | 'sync';
|
||||
/**
|
||||
* Return the raw input values rather than the parsed values.
|
||||
* @default false
|
||||
*/
|
||||
raw?: boolean;
|
||||
}): Resolver<Yup.InferType<typeof schema>>;
|
||||
2
frontend/node_modules/@hookform/resolvers/yup/dist/yup.js
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/yup/dist/yup.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
var e=require("@hookform/resolvers"),t=require("react-hook-form");exports.yupResolver=function(r,o,n){return void 0===o&&(o={}),void 0===n&&(n={}),function(s,a,i){try{return Promise.resolve(function(t,u){try{var c=(o.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(r["sync"===n.mode?"validateSync":"validate"](s,Object.assign({abortEarly:!1},o,{context:a}))).then(function(t){return i.shouldUseNativeValidation&&e.validateFieldsNatively({},i),{values:n.raw?s:t,errors:{}}}))}catch(e){return u(e)}return c&&c.then?c.then(void 0,u):c}(0,function(r){if(!r.inner)throw r;return{values:{},errors:e.toNestErrors((o=r,n=!i.shouldUseNativeValidation&&"all"===i.criteriaMode,(o.inner||[]).reduce(function(e,r){if(e[r.path]||(e[r.path]={message:r.message,type:r.type}),n){var o=e[r.path].types,s=o&&o[r.type];e[r.path]=t.appendErrors(r.path,n,e,r.type,s?[].concat(s,r.message):r.message)}return e},{})),i)};var o,n}))}catch(e){return Promise.reject(e)}}};
|
||||
//# sourceMappingURL=yup.js.map
|
||||
1
frontend/node_modules/@hookform/resolvers/yup/dist/yup.js.map
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/yup/dist/yup.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"yup.js","sources":["../src/yup.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\nimport * as Yup from 'yup';\n\n/**\n * Why `path!` ? because it could be `undefined` in some case\n * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string\n */\nconst parseErrorSchema = (\n error: Yup.ValidationError,\n validateAllFieldCriteria: boolean,\n) => {\n return (error.inner || []).reduce<Record<string, FieldError>>(\n (previous, error) => {\n if (!previous[error.path!]) {\n previous[error.path!] = { message: error.message, type: error.type! };\n }\n\n if (validateAllFieldCriteria) {\n const types = previous[error.path!].types;\n const messages = types && types[error.type!];\n\n previous[error.path!] = appendErrors(\n error.path!,\n validateAllFieldCriteria,\n previous,\n error.type!,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n return previous;\n },\n {},\n );\n};\n\nexport function yupResolver<TFieldValues extends FieldValues>(\n schema:\n | Yup.ObjectSchema<TFieldValues>\n | ReturnType<typeof Yup.lazy<Yup.ObjectSchema<TFieldValues>>>,\n schemaOptions: Parameters<(typeof schema)['validate']>[1] = {},\n resolverOptions: {\n /**\n * @default async\n */\n mode?: 'async' | 'sync';\n /**\n * Return the raw input values rather than the parsed values.\n * @default false\n */\n raw?: boolean;\n } = {},\n): Resolver<Yup.InferType<typeof schema>> {\n return async (values, context, options) => {\n try {\n if (schemaOptions.context && process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n \"You should not used the yup options context. Please, use the 'useForm' context object instead\",\n );\n }\n\n const result = await schema[\n resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'\n ](\n values,\n Object.assign({ abortEarly: false }, schemaOptions, { context }),\n );\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? values : result,\n errors: {},\n };\n } catch (e: any) {\n if (!e.inner) {\n throw e;\n }\n\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n e,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n };\n}\n"],"names":["schema","schemaOptions","resolverOptions","values","context","options","Promise","resolve","process","env","NODE_ENV","console","warn","mode","Object","assign","abortEarly","then","result","shouldUseNativeValidation","validateFieldsNatively","raw","errors","_catch","e","inner","toNestErrors","error","validateAllFieldCriteria","criteriaMode","reduce","previous","path","message","type","types","messages","appendErrors","concat","reject"],"mappings":"sFA4CgB,SACdA,EAGAC,EACAC,GAYA,YAbAD,IAAAA,IAAAA,EAA4D,CAAE,QAC9DC,IAAAA,IAAAA,EAUI,IAEUC,SAAAA,EAAQC,EAASC,GAAW,IAAA,OAAAC,QAAAC,iCAElCN,EAAcG,SAAoC,gBAAzBI,QAAQC,IAAIC,UAEvCC,QAAQC,KACN,iGAEHN,QAAAC,QAEoBP,EACM,SAAzBE,EAAgBW,KAAkB,eAAiB,YAEnDV,EACAW,OAAOC,OAAO,CAAEC,YAAY,GAASf,EAAe,CAAEG,QAAAA,MACvDa,cALKC,GASN,OAFAb,EAAQc,2BAA6BC,EAAAA,uBAAuB,CAAE,EAAEf,GAEzD,CACLF,OAAQD,EAAgBmB,IAAMlB,EAASe,EACvCI,OAAQ,CAAA,EACR,6DArBoCC,CAAA,WAsB/BC,GACP,IAAKA,EAAEC,MACL,MAAMD,EAGR,MAAO,CACLrB,OAAQ,CAAE,EACVmB,OAAQI,EAAAA,cA5EdC,EA8EUH,EA7EVI,GA8EWvB,EAAQc,2BACkB,QAAzBd,EAAQwB,cA7EZF,EAAMF,OAAS,IAAIK,OACzB,SAACC,EAAUJ,GAKT,GAJKI,EAASJ,EAAMK,QAClBD,EAASJ,EAAMK,MAAS,CAAEC,QAASN,EAAMM,QAASC,KAAMP,EAAMO,OAG5DN,EAA0B,CAC5B,IAAMO,EAAQJ,EAASJ,EAAMK,MAAOG,MAC9BC,EAAWD,GAASA,EAAMR,EAAMO,MAEtCH,EAASJ,EAAMK,MAASK,EAAAA,aACtBV,EAAMK,KACNJ,EACAG,EACAJ,EAAMO,KACNE,EACK,GAAgBE,OAAOF,EAAsBT,EAAMM,SACpDN,EAAMM,QAEd,CAEA,OAAOF,CACT,EACA,KAwDM1B,IAnFe,IACvBsB,EACAC,CAoFE,GACF,CAAC,MAAAJ,GAAA,OAAAlB,QAAAiC,OAAAf,EACH,CAAA,CAAA"}
|
||||
2
frontend/node_modules/@hookform/resolvers/yup/dist/yup.mjs
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/yup/dist/yup.mjs
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import{validateFieldsNatively as e,toNestErrors as t}from"@hookform/resolvers";import{appendErrors as r}from"react-hook-form";function o(o,n,a){return void 0===n&&(n={}),void 0===a&&(a={}),function(s,i,c){try{return Promise.resolve(function(t,r){try{var u=(n.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(o["sync"===a.mode?"validateSync":"validate"](s,Object.assign({abortEarly:!1},n,{context:i}))).then(function(t){return c.shouldUseNativeValidation&&e({},c),{values:a.raw?s:t,errors:{}}}))}catch(e){return r(e)}return u&&u.then?u.then(void 0,r):u}(0,function(e){if(!e.inner)throw e;return{values:{},errors:t((o=e,n=!c.shouldUseNativeValidation&&"all"===c.criteriaMode,(o.inner||[]).reduce(function(e,t){if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),n){var o=e[t.path].types,a=o&&o[t.type];e[t.path]=r(t.path,n,e,t.type,a?[].concat(a,t.message):t.message)}return e},{})),c)};var o,n}))}catch(e){return Promise.reject(e)}}}export{o as yupResolver};
|
||||
//# sourceMappingURL=yup.module.js.map
|
||||
2
frontend/node_modules/@hookform/resolvers/yup/dist/yup.modern.mjs
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/yup/dist/yup.modern.mjs
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import{validateFieldsNatively as e,toNestErrors as t}from"@hookform/resolvers";import{appendErrors as o}from"react-hook-form";function r(r,a={},s={}){return async(n,c,i)=>{try{a.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");const t=await r["sync"===s.mode?"validateSync":"validate"](n,Object.assign({abortEarly:!1},a,{context:c}));return i.shouldUseNativeValidation&&e({},i),{values:s.raw?n:t,errors:{}}}catch(e){if(!e.inner)throw e;return{values:{},errors:t((p=e,l=!i.shouldUseNativeValidation&&"all"===i.criteriaMode,(p.inner||[]).reduce((e,t)=>{if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),l){const r=e[t.path].types,a=r&&r[t.type];e[t.path]=o(t.path,l,e,t.type,a?[].concat(a,t.message):t.message)}return e},{})),i)}}var p,l}}export{r as yupResolver};
|
||||
//# sourceMappingURL=yup.modern.mjs.map
|
||||
1
frontend/node_modules/@hookform/resolvers/yup/dist/yup.modern.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/yup/dist/yup.modern.mjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"yup.modern.mjs","sources":["../src/yup.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\nimport * as Yup from 'yup';\n\n/**\n * Why `path!` ? because it could be `undefined` in some case\n * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string\n */\nconst parseErrorSchema = (\n error: Yup.ValidationError,\n validateAllFieldCriteria: boolean,\n) => {\n return (error.inner || []).reduce<Record<string, FieldError>>(\n (previous, error) => {\n if (!previous[error.path!]) {\n previous[error.path!] = { message: error.message, type: error.type! };\n }\n\n if (validateAllFieldCriteria) {\n const types = previous[error.path!].types;\n const messages = types && types[error.type!];\n\n previous[error.path!] = appendErrors(\n error.path!,\n validateAllFieldCriteria,\n previous,\n error.type!,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n return previous;\n },\n {},\n );\n};\n\nexport function yupResolver<TFieldValues extends FieldValues>(\n schema:\n | Yup.ObjectSchema<TFieldValues>\n | ReturnType<typeof Yup.lazy<Yup.ObjectSchema<TFieldValues>>>,\n schemaOptions: Parameters<(typeof schema)['validate']>[1] = {},\n resolverOptions: {\n /**\n * @default async\n */\n mode?: 'async' | 'sync';\n /**\n * Return the raw input values rather than the parsed values.\n * @default false\n */\n raw?: boolean;\n } = {},\n): Resolver<Yup.InferType<typeof schema>> {\n return async (values, context, options) => {\n try {\n if (schemaOptions.context && process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n \"You should not used the yup options context. Please, use the 'useForm' context object instead\",\n );\n }\n\n const result = await schema[\n resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'\n ](\n values,\n Object.assign({ abortEarly: false }, schemaOptions, { context }),\n );\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? values : result,\n errors: {},\n };\n } catch (e: any) {\n if (!e.inner) {\n throw e;\n }\n\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n e,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n };\n}\n"],"names":["yupResolver","schema","schemaOptions","resolverOptions","async","values","context","options","process","env","NODE_ENV","console","warn","result","mode","Object","assign","abortEarly","shouldUseNativeValidation","validateFieldsNatively","raw","errors","e","inner","toNestErrors","error","validateAllFieldCriteria","criteriaMode","reduce","previous","path","message","type","types","messages","appendErrors","concat","parseErrorSchema"],"mappings":"uIA4CgBA,EACdC,EAGAC,EAA4D,CAAE,EAC9DC,EAUI,CAAA,GAEJ,OAAOC,MAAOC,EAAQC,EAASC,KAC7B,IACML,EAAcI,SAAoC,gBAAzBE,QAAQC,IAAIC,UAEvCC,QAAQC,KACN,iGAIJ,MAAMC,QAAeZ,EACM,SAAzBE,EAAgBW,KAAkB,eAAiB,YAEnDT,EACAU,OAAOC,OAAO,CAAEC,YAAY,GAASf,EAAe,CAAEI,aAKxD,OAFAC,EAAQW,2BAA6BC,EAAuB,CAAA,EAAIZ,GAEzD,CACLF,OAAQF,EAAgBiB,IAAMf,EAASQ,EACvCQ,OAAQ,GAEZ,CAAE,MAAOC,GACP,IAAKA,EAAEC,MACL,MAAMD,EAGR,MAAO,CACLjB,OAAQ,CAAE,EACVgB,OAAQG,GA5EdC,EA8EUH,EA7EVI,GA8EWnB,EAAQW,2BACkB,QAAzBX,EAAQoB,cA7EZF,EAAMF,OAAS,IAAIK,OACzB,CAACC,EAAUJ,KAKT,GAJKI,EAASJ,EAAMK,QAClBD,EAASJ,EAAMK,MAAS,CAAEC,QAASN,EAAMM,QAASC,KAAMP,EAAMO,OAG5DN,EAA0B,CAC5B,MAAMO,EAAQJ,EAASJ,EAAMK,MAAOG,MAC9BC,EAAWD,GAASA,EAAMR,EAAMO,MAEtCH,EAASJ,EAAMK,MAASK,EACtBV,EAAMK,KACNJ,EACAG,EACAJ,EAAMO,KACNE,EACK,GAAgBE,OAAOF,EAAsBT,EAAMM,SACpDN,EAAMM,QAEd,CAEA,OAAOF,GAET,CAAE,IAwDItB,GAGN,CAtFqB8B,IACvBZ,EACAC,CAoFE,CAEJ"}
|
||||
2
frontend/node_modules/@hookform/resolvers/yup/dist/yup.module.js
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/yup/dist/yup.module.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import{validateFieldsNatively as e,toNestErrors as t}from"@hookform/resolvers";import{appendErrors as r}from"react-hook-form";function o(o,n,a){return void 0===n&&(n={}),void 0===a&&(a={}),function(s,i,c){try{return Promise.resolve(function(t,r){try{var u=(n.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(o["sync"===a.mode?"validateSync":"validate"](s,Object.assign({abortEarly:!1},n,{context:i}))).then(function(t){return c.shouldUseNativeValidation&&e({},c),{values:a.raw?s:t,errors:{}}}))}catch(e){return r(e)}return u&&u.then?u.then(void 0,r):u}(0,function(e){if(!e.inner)throw e;return{values:{},errors:t((o=e,n=!c.shouldUseNativeValidation&&"all"===c.criteriaMode,(o.inner||[]).reduce(function(e,t){if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),n){var o=e[t.path].types,a=o&&o[t.type];e[t.path]=r(t.path,n,e,t.type,a?[].concat(a,t.message):t.message)}return e},{})),c)};var o,n}))}catch(e){return Promise.reject(e)}}}export{o as yupResolver};
|
||||
//# sourceMappingURL=yup.module.js.map
|
||||
1
frontend/node_modules/@hookform/resolvers/yup/dist/yup.module.js.map
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/yup/dist/yup.module.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"yup.module.js","sources":["../src/yup.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\nimport * as Yup from 'yup';\n\n/**\n * Why `path!` ? because it could be `undefined` in some case\n * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string\n */\nconst parseErrorSchema = (\n error: Yup.ValidationError,\n validateAllFieldCriteria: boolean,\n) => {\n return (error.inner || []).reduce<Record<string, FieldError>>(\n (previous, error) => {\n if (!previous[error.path!]) {\n previous[error.path!] = { message: error.message, type: error.type! };\n }\n\n if (validateAllFieldCriteria) {\n const types = previous[error.path!].types;\n const messages = types && types[error.type!];\n\n previous[error.path!] = appendErrors(\n error.path!,\n validateAllFieldCriteria,\n previous,\n error.type!,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n return previous;\n },\n {},\n );\n};\n\nexport function yupResolver<TFieldValues extends FieldValues>(\n schema:\n | Yup.ObjectSchema<TFieldValues>\n | ReturnType<typeof Yup.lazy<Yup.ObjectSchema<TFieldValues>>>,\n schemaOptions: Parameters<(typeof schema)['validate']>[1] = {},\n resolverOptions: {\n /**\n * @default async\n */\n mode?: 'async' | 'sync';\n /**\n * Return the raw input values rather than the parsed values.\n * @default false\n */\n raw?: boolean;\n } = {},\n): Resolver<Yup.InferType<typeof schema>> {\n return async (values, context, options) => {\n try {\n if (schemaOptions.context && process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n \"You should not used the yup options context. Please, use the 'useForm' context object instead\",\n );\n }\n\n const result = await schema[\n resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'\n ](\n values,\n Object.assign({ abortEarly: false }, schemaOptions, { context }),\n );\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? values : result,\n errors: {},\n };\n } catch (e: any) {\n if (!e.inner) {\n throw e;\n }\n\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n e,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n };\n}\n"],"names":["yupResolver","schema","schemaOptions","resolverOptions","values","context","options","Promise","resolve","process","env","NODE_ENV","console","warn","mode","Object","assign","abortEarly","then","result","shouldUseNativeValidation","validateFieldsNatively","raw","errors","_catch","e","inner","toNestErrors","error","validateAllFieldCriteria","criteriaMode","reduce","previous","path","message","type","types","messages","appendErrors","concat","reject"],"mappings":"8HA4CgB,SAAAA,EACdC,EAGAC,EACAC,GAYA,YAbAD,IAAAA,IAAAA,EAA4D,CAAE,QAC9DC,IAAAA,IAAAA,EAUI,IAEUC,SAAAA,EAAQC,EAASC,GAAW,IAAA,OAAAC,QAAAC,iCAElCN,EAAcG,SAAoC,gBAAzBI,QAAQC,IAAIC,UAEvCC,QAAQC,KACN,iGAEHN,QAAAC,QAEoBP,EACM,SAAzBE,EAAgBW,KAAkB,eAAiB,YAEnDV,EACAW,OAAOC,OAAO,CAAEC,YAAY,GAASf,EAAe,CAAEG,QAAAA,MACvDa,cALKC,GASN,OAFAb,EAAQc,2BAA6BC,EAAuB,CAAE,EAAEf,GAEzD,CACLF,OAAQD,EAAgBmB,IAAMlB,EAASe,EACvCI,OAAQ,CAAA,EACR,6DArBoCC,CAAA,WAsB/BC,GACP,IAAKA,EAAEC,MACL,MAAMD,EAGR,MAAO,CACLrB,OAAQ,CAAE,EACVmB,OAAQI,GA5EdC,EA8EUH,EA7EVI,GA8EWvB,EAAQc,2BACkB,QAAzBd,EAAQwB,cA7EZF,EAAMF,OAAS,IAAIK,OACzB,SAACC,EAAUJ,GAKT,GAJKI,EAASJ,EAAMK,QAClBD,EAASJ,EAAMK,MAAS,CAAEC,QAASN,EAAMM,QAASC,KAAMP,EAAMO,OAG5DN,EAA0B,CAC5B,IAAMO,EAAQJ,EAASJ,EAAMK,MAAOG,MAC9BC,EAAWD,GAASA,EAAMR,EAAMO,MAEtCH,EAASJ,EAAMK,MAASK,EACtBV,EAAMK,KACNJ,EACAG,EACAJ,EAAMO,KACNE,EACK,GAAgBE,OAAOF,EAAsBT,EAAMM,SACpDN,EAAMM,QAEd,CAEA,OAAOF,CACT,EACA,KAwDM1B,IAnFe,IACvBsB,EACAC,CAoFE,GACF,CAAC,MAAAJ,GAAA,OAAAlB,QAAAiC,OAAAf,EACH,CAAA,CAAA"}
|
||||
2
frontend/node_modules/@hookform/resolvers/yup/dist/yup.umd.js
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/yup/dist/yup.umd.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("@hookform/resolvers"),require("react-hook-form")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","react-hook-form"],o):o((e||self).hookformResolversYup={},e.hookformResolvers,e.ReactHookForm)}(this,function(e,o,t){e.yupResolver=function(e,r,n){return void 0===r&&(r={}),void 0===n&&(n={}),function(s,a,i){try{return Promise.resolve(function(t,u){try{var c=(r.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(e["sync"===n.mode?"validateSync":"validate"](s,Object.assign({abortEarly:!1},r,{context:a}))).then(function(e){return i.shouldUseNativeValidation&&o.validateFieldsNatively({},i),{values:n.raw?s:e,errors:{}}}))}catch(e){return u(e)}return c&&c.then?c.then(void 0,u):c}(0,function(e){if(!e.inner)throw e;return{values:{},errors:o.toNestErrors((r=e,n=!i.shouldUseNativeValidation&&"all"===i.criteriaMode,(r.inner||[]).reduce(function(e,o){if(e[o.path]||(e[o.path]={message:o.message,type:o.type}),n){var r=e[o.path].types,s=r&&r[o.type];e[o.path]=t.appendErrors(o.path,n,e,o.type,s?[].concat(s,o.message):o.message)}return e},{})),i)};var r,n}))}catch(e){return Promise.reject(e)}}}});
|
||||
//# sourceMappingURL=yup.umd.js.map
|
||||
1
frontend/node_modules/@hookform/resolvers/yup/dist/yup.umd.js.map
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/yup/dist/yup.umd.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"yup.umd.js","sources":["../src/yup.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport {\n FieldError,\n FieldValues,\n Resolver,\n appendErrors,\n} from 'react-hook-form';\nimport * as Yup from 'yup';\n\n/**\n * Why `path!` ? because it could be `undefined` in some case\n * https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string\n */\nconst parseErrorSchema = (\n error: Yup.ValidationError,\n validateAllFieldCriteria: boolean,\n) => {\n return (error.inner || []).reduce<Record<string, FieldError>>(\n (previous, error) => {\n if (!previous[error.path!]) {\n previous[error.path!] = { message: error.message, type: error.type! };\n }\n\n if (validateAllFieldCriteria) {\n const types = previous[error.path!].types;\n const messages = types && types[error.type!];\n\n previous[error.path!] = appendErrors(\n error.path!,\n validateAllFieldCriteria,\n previous,\n error.type!,\n messages\n ? ([] as string[]).concat(messages as string[], error.message)\n : error.message,\n ) as FieldError;\n }\n\n return previous;\n },\n {},\n );\n};\n\nexport function yupResolver<TFieldValues extends FieldValues>(\n schema:\n | Yup.ObjectSchema<TFieldValues>\n | ReturnType<typeof Yup.lazy<Yup.ObjectSchema<TFieldValues>>>,\n schemaOptions: Parameters<(typeof schema)['validate']>[1] = {},\n resolverOptions: {\n /**\n * @default async\n */\n mode?: 'async' | 'sync';\n /**\n * Return the raw input values rather than the parsed values.\n * @default false\n */\n raw?: boolean;\n } = {},\n): Resolver<Yup.InferType<typeof schema>> {\n return async (values, context, options) => {\n try {\n if (schemaOptions.context && process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n \"You should not used the yup options context. Please, use the 'useForm' context object instead\",\n );\n }\n\n const result = await schema[\n resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'\n ](\n values,\n Object.assign({ abortEarly: false }, schemaOptions, { context }),\n );\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? values : result,\n errors: {},\n };\n } catch (e: any) {\n if (!e.inner) {\n throw e;\n }\n\n return {\n values: {},\n errors: toNestErrors(\n parseErrorSchema(\n e,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n };\n}\n"],"names":["schema","schemaOptions","resolverOptions","values","context","options","Promise","resolve","process","env","NODE_ENV","console","warn","mode","Object","assign","abortEarly","then","result","shouldUseNativeValidation","validateFieldsNatively","raw","errors","_catch","e","inner","toNestErrors","error","validateAllFieldCriteria","criteriaMode","reduce","previous","path","message","type","types","messages","appendErrors","concat","reject"],"mappings":"sYA4CgB,SACdA,EAGAC,EACAC,GAYA,YAbAD,IAAAA,IAAAA,EAA4D,CAAE,QAC9DC,IAAAA,IAAAA,EAUI,IAEUC,SAAAA,EAAQC,EAASC,GAAW,IAAA,OAAAC,QAAAC,iCAElCN,EAAcG,SAAoC,gBAAzBI,QAAQC,IAAIC,UAEvCC,QAAQC,KACN,iGAEHN,QAAAC,QAEoBP,EACM,SAAzBE,EAAgBW,KAAkB,eAAiB,YAEnDV,EACAW,OAAOC,OAAO,CAAEC,YAAY,GAASf,EAAe,CAAEG,QAAAA,MACvDa,cALKC,GASN,OAFAb,EAAQc,2BAA6BC,EAAAA,uBAAuB,CAAE,EAAEf,GAEzD,CACLF,OAAQD,EAAgBmB,IAAMlB,EAASe,EACvCI,OAAQ,CAAA,EACR,6DArBoCC,CAAA,WAsB/BC,GACP,IAAKA,EAAEC,MACL,MAAMD,EAGR,MAAO,CACLrB,OAAQ,CAAE,EACVmB,OAAQI,EAAAA,cA5EdC,EA8EUH,EA7EVI,GA8EWvB,EAAQc,2BACkB,QAAzBd,EAAQwB,cA7EZF,EAAMF,OAAS,IAAIK,OACzB,SAACC,EAAUJ,GAKT,GAJKI,EAASJ,EAAMK,QAClBD,EAASJ,EAAMK,MAAS,CAAEC,QAASN,EAAMM,QAASC,KAAMP,EAAMO,OAG5DN,EAA0B,CAC5B,IAAMO,EAAQJ,EAASJ,EAAMK,MAAOG,MAC9BC,EAAWD,GAASA,EAAMR,EAAMO,MAEtCH,EAASJ,EAAMK,MAASK,EAAAA,aACtBV,EAAMK,KACNJ,EACAG,EACAJ,EAAMO,KACNE,EACK,GAAgBE,OAAOF,EAAsBT,EAAMM,SACpDN,EAAMM,QAEd,CAEA,OAAOF,CACT,EACA,KAwDM1B,IAnFe,IACvBsB,EACAC,CAoFE,GACF,CAAC,MAAAJ,GAAA,OAAAlB,QAAAiC,OAAAf,EACH,CAAA,CAAA"}
|
||||
17
frontend/node_modules/@hookform/resolvers/yup/package.json
generated
vendored
Normal file
17
frontend/node_modules/@hookform/resolvers/yup/package.json
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@hookform/resolvers/yup",
|
||||
"amdName": "hookformResolversYup",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "React Hook Form validation resolver: yup",
|
||||
"main": "dist/yup.js",
|
||||
"module": "dist/yup.module.js",
|
||||
"umd:main": "dist/yup.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/yup/src/__tests__/Form-native-validation.tsx
generated
vendored
Normal file
81
frontend/node_modules/@hookform/resolvers/yup/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 * as Yup from 'yup';
|
||||
import { yupResolver } from '..';
|
||||
|
||||
const USERNAME_REQUIRED_MESSAGE = 'username field is required';
|
||||
const PASSWORD_REQUIRED_MESSAGE = 'password field is required';
|
||||
|
||||
const schema = Yup.object({
|
||||
username: Yup.string().required(USERNAME_REQUIRED_MESSAGE),
|
||||
password: Yup.string().required(PASSWORD_REQUIRED_MESSAGE),
|
||||
});
|
||||
|
||||
type FormData = Yup.InferType<typeof schema>;
|
||||
|
||||
interface Props {
|
||||
onSubmit: (data: FormData) => void;
|
||||
}
|
||||
|
||||
function TestComponent({ onSubmit }: Props) {
|
||||
const { register, handleSubmit } = useForm<FormData>({
|
||||
resolver: yupResolver(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 Yup", 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/yup/src/__tests__/Form.tsx
generated
vendored
Normal file
52
frontend/node_modules/@hookform/resolvers/yup/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 { SubmitHandler, useForm } from 'react-hook-form';
|
||||
import * as Yup from 'yup';
|
||||
import { yupResolver } from '..';
|
||||
|
||||
const schema = Yup.object({
|
||||
username: Yup.string().required(),
|
||||
password: Yup.string().required(),
|
||||
});
|
||||
|
||||
type FormData = Yup.InferType<typeof schema>;
|
||||
|
||||
interface Props {
|
||||
onSubmit: SubmitHandler<FormData>;
|
||||
}
|
||||
|
||||
function TestComponent({ onSubmit }: Props) {
|
||||
const {
|
||||
register,
|
||||
formState: { errors },
|
||||
handleSubmit,
|
||||
} = useForm({
|
||||
resolver: yupResolver(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 Yup 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 is a required field/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/password is a required field/i)).toBeInTheDocument();
|
||||
expect(handleSubmit).not.toHaveBeenCalled();
|
||||
});
|
||||
80
frontend/node_modules/@hookform/resolvers/yup/src/__tests__/__fixtures__/data.ts
generated
vendored
Normal file
80
frontend/node_modules/@hookform/resolvers/yup/src/__tests__/__fixtures__/data.ts
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
import { Field, InternalFieldName } from 'react-hook-form';
|
||||
import * as yup from 'yup';
|
||||
|
||||
export const schema = yup.object({
|
||||
username: yup.string().matches(/^\w+$/).min(3).max(30).required(),
|
||||
password: yup
|
||||
.string()
|
||||
.matches(new RegExp('.*[A-Z].*'), 'One uppercase character')
|
||||
.matches(new RegExp('.*[a-z].*'), 'One lowercase character')
|
||||
.matches(new RegExp('.*\\d.*'), 'One number')
|
||||
.matches(
|
||||
new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'),
|
||||
'One special character',
|
||||
)
|
||||
.min(8, 'Must be at least 8 characters in length')
|
||||
.required('New Password is required'),
|
||||
repeatPassword: yup.ref('password'),
|
||||
accessToken: yup.string(),
|
||||
birthYear: yup.number().min(1900).max(2013),
|
||||
email: yup.string().email(),
|
||||
tags: yup.array(yup.string()),
|
||||
enabled: yup.boolean(),
|
||||
like: yup.array().of(
|
||||
yup.object({
|
||||
id: yup.number().required(),
|
||||
name: yup.string().length(4).required(),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
export const schemaWithWhen = yup.object({
|
||||
name: yup.string().required(),
|
||||
value: yup.string().when('name', ([name], schema) => {
|
||||
return name === 'test' ? yup.number().required() : schema;
|
||||
}),
|
||||
});
|
||||
|
||||
export const validData = {
|
||||
username: 'Doe',
|
||||
password: 'Password123_',
|
||||
repeatPassword: 'Password123_',
|
||||
birthYear: 2000,
|
||||
email: 'john@doe.com',
|
||||
tags: ['tag1', 'tag2'],
|
||||
enabled: true,
|
||||
accessToken: 'accessToken',
|
||||
like: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'name',
|
||||
},
|
||||
],
|
||||
} satisfies yup.InferType<typeof schema>;
|
||||
|
||||
export const invalidData = {
|
||||
password: '___',
|
||||
email: '',
|
||||
birthYear: 'birthYear',
|
||||
like: [{ id: 'z' }],
|
||||
// Must be set to "unknown", otherwise typescript knows that it is invalid
|
||||
} as unknown as Required<yup.InferType<typeof schema>>;
|
||||
|
||||
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',
|
||||
},
|
||||
};
|
||||
244
frontend/node_modules/@hookform/resolvers/yup/src/__tests__/__snapshots__/yup.ts.snap
generated
vendored
Normal file
244
frontend/node_modules/@hookform/resolvers/yup/src/__tests__/__snapshots__/yup.ts.snap
generated
vendored
Normal file
@ -0,0 +1,244 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`yupResolver > should return a single error from yupResolver when validation fails 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"birthYear": {
|
||||
"message": "birthYear must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"birthYear"\`).",
|
||||
"ref": undefined,
|
||||
"type": "typeError",
|
||||
},
|
||||
"like": [
|
||||
{
|
||||
"id": {
|
||||
"message": "like[0].id must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"z"\`).",
|
||||
"ref": undefined,
|
||||
"type": "typeError",
|
||||
},
|
||||
"name": {
|
||||
"message": "like[0].name is a required field",
|
||||
"ref": undefined,
|
||||
"type": "optionality",
|
||||
},
|
||||
},
|
||||
],
|
||||
"password": {
|
||||
"message": "One uppercase character",
|
||||
"ref": {
|
||||
"name": "password",
|
||||
},
|
||||
"type": "matches",
|
||||
},
|
||||
"username": {
|
||||
"message": "username is a required field",
|
||||
"ref": {
|
||||
"name": "username",
|
||||
},
|
||||
"type": "optionality",
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`yupResolver > should return a single error from yupResolver with \`mode: sync\` when validation fails 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"birthYear": {
|
||||
"message": "birthYear must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"birthYear"\`).",
|
||||
"ref": undefined,
|
||||
"type": "typeError",
|
||||
},
|
||||
"like": [
|
||||
{
|
||||
"id": {
|
||||
"message": "like[0].id must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"z"\`).",
|
||||
"ref": undefined,
|
||||
"type": "typeError",
|
||||
},
|
||||
"name": {
|
||||
"message": "like[0].name is a required field",
|
||||
"ref": undefined,
|
||||
"type": "optionality",
|
||||
},
|
||||
},
|
||||
],
|
||||
"password": {
|
||||
"message": "One uppercase character",
|
||||
"ref": {
|
||||
"name": "password",
|
||||
},
|
||||
"type": "matches",
|
||||
},
|
||||
"username": {
|
||||
"message": "username is a required field",
|
||||
"ref": {
|
||||
"name": "username",
|
||||
},
|
||||
"type": "optionality",
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`yupResolver > should return all the errors from yupResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"birthYear": {
|
||||
"message": "birthYear must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"birthYear"\`).",
|
||||
"ref": undefined,
|
||||
"type": "typeError",
|
||||
"types": {
|
||||
"typeError": "birthYear must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"birthYear"\`).",
|
||||
},
|
||||
},
|
||||
"like": [
|
||||
{
|
||||
"id": {
|
||||
"message": "like[0].id must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"z"\`).",
|
||||
"ref": undefined,
|
||||
"type": "typeError",
|
||||
"types": {
|
||||
"typeError": "like[0].id must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"z"\`).",
|
||||
},
|
||||
},
|
||||
"name": {
|
||||
"message": "like[0].name is a required field",
|
||||
"ref": undefined,
|
||||
"type": "optionality",
|
||||
"types": {
|
||||
"optionality": "like[0].name is a required field",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"password": {
|
||||
"message": "One uppercase character",
|
||||
"ref": {
|
||||
"name": "password",
|
||||
},
|
||||
"type": "matches",
|
||||
"types": {
|
||||
"matches": [
|
||||
"One uppercase character",
|
||||
"One lowercase character",
|
||||
"One number",
|
||||
],
|
||||
"min": "Must be at least 8 characters in length",
|
||||
},
|
||||
},
|
||||
"username": {
|
||||
"message": "username is a required field",
|
||||
"ref": {
|
||||
"name": "username",
|
||||
},
|
||||
"type": "optionality",
|
||||
"types": {
|
||||
"optionality": "username is a required field",
|
||||
},
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`yupResolver > should return all the errors from yupResolver when validation fails with \`validateAllFieldCriteria\` set to true and \`mode: sync\` 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"birthYear": {
|
||||
"message": "birthYear must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"birthYear"\`).",
|
||||
"ref": undefined,
|
||||
"type": "typeError",
|
||||
"types": {
|
||||
"typeError": "birthYear must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"birthYear"\`).",
|
||||
},
|
||||
},
|
||||
"like": [
|
||||
{
|
||||
"id": {
|
||||
"message": "like[0].id must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"z"\`).",
|
||||
"ref": undefined,
|
||||
"type": "typeError",
|
||||
"types": {
|
||||
"typeError": "like[0].id must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`"z"\`).",
|
||||
},
|
||||
},
|
||||
"name": {
|
||||
"message": "like[0].name is a required field",
|
||||
"ref": undefined,
|
||||
"type": "optionality",
|
||||
"types": {
|
||||
"optionality": "like[0].name is a required field",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"password": {
|
||||
"message": "One uppercase character",
|
||||
"ref": {
|
||||
"name": "password",
|
||||
},
|
||||
"type": "matches",
|
||||
"types": {
|
||||
"matches": [
|
||||
"One uppercase character",
|
||||
"One lowercase character",
|
||||
"One number",
|
||||
],
|
||||
"min": "Must be at least 8 characters in length",
|
||||
},
|
||||
},
|
||||
"username": {
|
||||
"message": "username is a required field",
|
||||
"ref": {
|
||||
"name": "username",
|
||||
},
|
||||
"type": "optionality",
|
||||
"types": {
|
||||
"optionality": "username is a required field",
|
||||
},
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`yupResolver > should return an error from yupResolver when validation fails and pass down the yup context 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"name": {
|
||||
"message": "name must be at least 6 characters",
|
||||
"ref": undefined,
|
||||
"type": "min",
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`yupResolver > should return correct error message with using yup.test 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"": {
|
||||
"message": "Email or name are required",
|
||||
"ref": undefined,
|
||||
"type": "name",
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`yupResolver > should throw an error without inner property 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"value": {
|
||||
"message": "value must be a \`number\` type, but the final value was: \`NaN\` (cast from the value \`""\`).",
|
||||
"ref": undefined,
|
||||
"type": "typeError",
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
219
frontend/node_modules/@hookform/resolvers/yup/src/__tests__/yup.ts
generated
vendored
Normal file
219
frontend/node_modules/@hookform/resolvers/yup/src/__tests__/yup.ts
generated
vendored
Normal file
@ -0,0 +1,219 @@
|
||||
/* eslint-disable no-console, @typescript-eslint/ban-ts-comment */
|
||||
import * as yup from 'yup';
|
||||
import { yupResolver } from '..';
|
||||
import {
|
||||
fields,
|
||||
invalidData,
|
||||
schema,
|
||||
schemaWithWhen,
|
||||
validData,
|
||||
} from './__fixtures__/data';
|
||||
|
||||
const shouldUseNativeValidation = false;
|
||||
|
||||
describe('yupResolver', () => {
|
||||
it('should return values from yupResolver when validation pass', async () => {
|
||||
const schemaSpy = vi.spyOn(schema, 'validate');
|
||||
const schemaSyncSpy = vi.spyOn(schema, 'validateSync');
|
||||
|
||||
const result = await yupResolver(schema)(validData, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(schemaSpy).toHaveBeenCalledTimes(1);
|
||||
expect(schemaSyncSpy).not.toHaveBeenCalled();
|
||||
expect(result).toEqual({ errors: {}, values: validData });
|
||||
});
|
||||
|
||||
it('should return values from yupResolver with `mode: sync` when validation pass', async () => {
|
||||
const validateSyncSpy = vi.spyOn(schema, 'validateSync');
|
||||
const validateSpy = vi.spyOn(schema, 'validate');
|
||||
|
||||
const result = await yupResolver(schema, undefined, {
|
||||
mode: 'sync',
|
||||
})(validData, undefined, { fields, shouldUseNativeValidation });
|
||||
|
||||
expect(validateSyncSpy).toHaveBeenCalledTimes(1);
|
||||
expect(validateSpy).not.toHaveBeenCalled();
|
||||
expect(result).toEqual({ errors: {}, values: validData });
|
||||
});
|
||||
|
||||
it('should return a single error from yupResolver when validation fails', async () => {
|
||||
const result = await yupResolver(schema)(invalidData, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return a single error from yupResolver with `mode: sync` when validation fails', async () => {
|
||||
const validateSyncSpy = vi.spyOn(schema, 'validateSync');
|
||||
const validateSpy = vi.spyOn(schema, 'validate');
|
||||
|
||||
const result = await yupResolver(schema, undefined, {
|
||||
mode: 'sync',
|
||||
})(invalidData, undefined, { fields, shouldUseNativeValidation });
|
||||
|
||||
expect(validateSyncSpy).toHaveBeenCalledTimes(1);
|
||||
expect(validateSpy).not.toHaveBeenCalled();
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return all the errors from yupResolver when validation fails with `validateAllFieldCriteria` set to true', async () => {
|
||||
const result = await yupResolver(schema)(invalidData, undefined, {
|
||||
fields,
|
||||
criteriaMode: 'all',
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return all the errors from yupResolver when validation fails with `validateAllFieldCriteria` set to true and `mode: sync`', async () => {
|
||||
const result = await yupResolver(schema, undefined, { mode: 'sync' })(
|
||||
invalidData,
|
||||
undefined,
|
||||
{
|
||||
fields,
|
||||
criteriaMode: 'all',
|
||||
shouldUseNativeValidation,
|
||||
},
|
||||
);
|
||||
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return an error from yupResolver when validation fails and pass down the yup context', async () => {
|
||||
const data = { name: 'eric' };
|
||||
const context = { min: true };
|
||||
const schemaWithContext = yup.object({
|
||||
name: yup
|
||||
.string()
|
||||
.required()
|
||||
.when('$min', ([min], schema) => {
|
||||
return min ? schema.min(6) : schema;
|
||||
}),
|
||||
});
|
||||
|
||||
const validateSpy = vi.spyOn(schemaWithContext, 'validate');
|
||||
|
||||
const result = await yupResolver(schemaWithContext)(data, context, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
expect(validateSpy).toHaveBeenCalledTimes(1);
|
||||
expect(validateSpy).toHaveBeenCalledWith(
|
||||
data,
|
||||
expect.objectContaining({
|
||||
abortEarly: false,
|
||||
context,
|
||||
}),
|
||||
);
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return correct error message with using yup.test', async () => {
|
||||
const result = await yupResolver(
|
||||
yup
|
||||
.object({
|
||||
name: yup.string(),
|
||||
email: yup.string(),
|
||||
})
|
||||
.test(
|
||||
'name',
|
||||
'Email or name are required',
|
||||
(value) => !!(value && (value.name || value.email)),
|
||||
),
|
||||
)({ name: '', email: '' }, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should merge default yup resolver options with yup's options", async () => {
|
||||
const validateSpy = vi.spyOn(schema, 'validate');
|
||||
|
||||
await yupResolver(schema, { stripUnknown: true })(invalidData, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(validateSpy.mock.calls[0][1]).toEqual(
|
||||
expect.objectContaining({ stripUnknown: true, abortEarly: false }),
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw an error without inner property', async () => {
|
||||
const result = await yupResolver(schemaWithWhen)(
|
||||
{ name: 'test', value: '' },
|
||||
undefined,
|
||||
{
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
},
|
||||
);
|
||||
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should throw any error unrelated to Yup', async () => {
|
||||
const schemaWithCustomError = schema.transform(() => {
|
||||
throw Error('custom error');
|
||||
});
|
||||
const promise = yupResolver(schemaWithCustomError)(validData, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
await expect(promise).rejects.toThrow('custom error');
|
||||
});
|
||||
|
||||
it('should return values from yupResolver when validation pass & raw=true', async () => {
|
||||
const schemaSpy = vi.spyOn(schema, 'validate');
|
||||
const schemaSyncSpy = vi.spyOn(schema, 'validateSync');
|
||||
|
||||
const result = await yupResolver(schema, undefined, { raw: true })(
|
||||
validData,
|
||||
undefined,
|
||||
{
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
},
|
||||
);
|
||||
|
||||
expect(schemaSpy).toHaveBeenCalledTimes(1);
|
||||
expect(schemaSyncSpy).not.toHaveBeenCalled();
|
||||
expect(result).toEqual({ errors: {}, values: validData });
|
||||
});
|
||||
|
||||
it('shoud validate a lazy schema with success', async () => {
|
||||
const lazySchema = yup.lazy(() =>
|
||||
yup.object().shape({ firstName: yup.string().optional() }),
|
||||
);
|
||||
|
||||
const schemaSpy = vi.spyOn(lazySchema, 'validate');
|
||||
const schemaSyncSpy = vi.spyOn(lazySchema, 'validateSync');
|
||||
|
||||
const result = await yupResolver(lazySchema, undefined)(
|
||||
{ firstName: 'resolver' },
|
||||
undefined,
|
||||
{
|
||||
fields: {
|
||||
firstName: {
|
||||
ref: { name: 'firstName' },
|
||||
name: 'firstName',
|
||||
},
|
||||
},
|
||||
shouldUseNativeValidation,
|
||||
},
|
||||
);
|
||||
|
||||
expect(schemaSpy).toHaveBeenCalledTimes(1);
|
||||
expect(schemaSyncSpy).not.toHaveBeenCalled();
|
||||
expect(result).toEqual({ errors: {}, values: { firstName: 'resolver' } });
|
||||
});
|
||||
});
|
||||
1
frontend/node_modules/@hookform/resolvers/yup/src/index.ts
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/yup/src/index.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export * from './yup';
|
||||
102
frontend/node_modules/@hookform/resolvers/yup/src/yup.ts
generated
vendored
Normal file
102
frontend/node_modules/@hookform/resolvers/yup/src/yup.ts
generated
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';
|
||||
import {
|
||||
FieldError,
|
||||
FieldValues,
|
||||
Resolver,
|
||||
appendErrors,
|
||||
} from 'react-hook-form';
|
||||
import * as Yup from 'yup';
|
||||
|
||||
/**
|
||||
* Why `path!` ? because it could be `undefined` in some case
|
||||
* https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string
|
||||
*/
|
||||
const parseErrorSchema = (
|
||||
error: Yup.ValidationError,
|
||||
validateAllFieldCriteria: boolean,
|
||||
) => {
|
||||
return (error.inner || []).reduce<Record<string, FieldError>>(
|
||||
(previous, error) => {
|
||||
if (!previous[error.path!]) {
|
||||
previous[error.path!] = { message: error.message, type: error.type! };
|
||||
}
|
||||
|
||||
if (validateAllFieldCriteria) {
|
||||
const types = previous[error.path!].types;
|
||||
const messages = types && types[error.type!];
|
||||
|
||||
previous[error.path!] = appendErrors(
|
||||
error.path!,
|
||||
validateAllFieldCriteria,
|
||||
previous,
|
||||
error.type!,
|
||||
messages
|
||||
? ([] as string[]).concat(messages as string[], error.message)
|
||||
: error.message,
|
||||
) as FieldError;
|
||||
}
|
||||
|
||||
return previous;
|
||||
},
|
||||
{},
|
||||
);
|
||||
};
|
||||
|
||||
export function yupResolver<TFieldValues extends FieldValues>(
|
||||
schema:
|
||||
| Yup.ObjectSchema<TFieldValues>
|
||||
| ReturnType<typeof Yup.lazy<Yup.ObjectSchema<TFieldValues>>>,
|
||||
schemaOptions: Parameters<(typeof schema)['validate']>[1] = {},
|
||||
resolverOptions: {
|
||||
/**
|
||||
* @default async
|
||||
*/
|
||||
mode?: 'async' | 'sync';
|
||||
/**
|
||||
* Return the raw input values rather than the parsed values.
|
||||
* @default false
|
||||
*/
|
||||
raw?: boolean;
|
||||
} = {},
|
||||
): Resolver<Yup.InferType<typeof schema>> {
|
||||
return async (values, context, options) => {
|
||||
try {
|
||||
if (schemaOptions.context && process.env.NODE_ENV === 'development') {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
"You should not used the yup options context. Please, use the 'useForm' context object instead",
|
||||
);
|
||||
}
|
||||
|
||||
const result = await schema[
|
||||
resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'
|
||||
](
|
||||
values,
|
||||
Object.assign({ abortEarly: false }, schemaOptions, { context }),
|
||||
);
|
||||
|
||||
options.shouldUseNativeValidation && validateFieldsNatively({}, options);
|
||||
|
||||
return {
|
||||
values: resolverOptions.raw ? values : result,
|
||||
errors: {},
|
||||
};
|
||||
} catch (e: any) {
|
||||
if (!e.inner) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
return {
|
||||
values: {},
|
||||
errors: toNestErrors(
|
||||
parseErrorSchema(
|
||||
e,
|
||||
!options.shouldUseNativeValidation &&
|
||||
options.criteriaMode === 'all',
|
||||
),
|
||||
options,
|
||||
),
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user