v1.0 with SW PWA enabled
This commit is contained in:
2
frontend/node_modules/@hookform/resolvers/valibot/dist/index.d.ts
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/valibot/dist/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './valibot';
|
||||
export * from './types';
|
||||
13
frontend/node_modules/@hookform/resolvers/valibot/dist/types.d.ts
generated
vendored
Normal file
13
frontend/node_modules/@hookform/resolvers/valibot/dist/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
|
||||
import { BaseIssue, BaseSchema, BaseSchemaAsync, Config, InferIssue } from 'valibot';
|
||||
export type Resolver = <T extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>>(schema: T, schemaOptions?: Partial<Omit<Config<InferIssue<T>>, 'abortPipeEarly' | 'skipPipe'>>, resolverOptions?: {
|
||||
/**
|
||||
* @default async
|
||||
*/
|
||||
mode?: 'sync' | 'async';
|
||||
/**
|
||||
* 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/valibot/dist/valibot.d.ts
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import type { Resolver } from './types';
|
||||
export declare const valibotResolver: Resolver;
|
||||
2
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.js
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
var e=require("@hookform/resolvers"),r=require("react-hook-form"),s=require("valibot");exports.valibotResolver=function(t,o,a){return void 0===a&&(a={}),function(i,u,n){try{var v=!n.shouldUseNativeValidation&&"all"===n.criteriaMode;return Promise.resolve(s.safeParseAsync(t,i,Object.assign({},o,{abortPipeEarly:!v}))).then(function(t){if(t.issues){for(var o={};t.issues.length;){var u=t.issues[0],l=s.getDotPath(u);if(l&&(o[l]||(o[l]={message:u.message,type:u.type}),v)){var c=o[l].types,f=c&&c[u.type];o[l]=r.appendErrors(l,v,o,u.type,f?[].concat(f,u.message):u.message)}t.issues.shift()}return{values:{},errors:e.toNestErrors(o,n)}}return{values:a.raw?i:t.output,errors:{}}})}catch(e){return Promise.reject(e)}}};
|
||||
//# sourceMappingURL=valibot.js.map
|
||||
1
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.js.map
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"valibot.js","sources":["../src/valibot.ts"],"sourcesContent":["import { toNestErrors } from '@hookform/resolvers';\nimport { FieldError, FieldValues, appendErrors } from 'react-hook-form';\nimport { getDotPath, safeParseAsync } from 'valibot';\nimport type { Resolver } from './types';\n\nexport const valibotResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n async (values, _, options) => {\n // Check if we should validate all field criteria\n const validateAllFieldCriteria =\n !options.shouldUseNativeValidation && options.criteriaMode === 'all';\n\n // Parse values with Valibot schema\n const result = await safeParseAsync(\n schema,\n values,\n Object.assign({}, schemaOptions, {\n abortPipeEarly: !validateAllFieldCriteria,\n }),\n );\n\n // If there are issues, return them as errors\n if (result.issues) {\n // Create errors object\n const errors: Record<string, FieldError> = {};\n\n // Iterate over issues to add them to errors object\n for (; result.issues.length; ) {\n const issue = result.issues[0];\n // Create dot path from issue\n const path = getDotPath(issue);\n\n if (path) {\n // Add first error of path to errors object\n if (!errors[path]) {\n errors[path] = { message: issue.message, type: issue.type };\n }\n\n // If configured, add all errors of path to errors object\n if (validateAllFieldCriteria) {\n const types = errors[path].types;\n const messages = types && types[issue.type];\n errors[path] = appendErrors(\n path,\n validateAllFieldCriteria,\n errors,\n issue.type,\n messages\n ? ([] as string[]).concat(\n messages as string | string[],\n issue.message,\n )\n : issue.message,\n ) as FieldError;\n }\n }\n\n result.issues.shift();\n }\n\n // Return resolver result with errors\n return {\n values: {},\n errors: toNestErrors(errors, options),\n } as const;\n }\n\n // Otherwise, return resolver result with values\n return {\n values: resolverOptions.raw ? values : (result.output as FieldValues),\n errors: {},\n };\n };\n"],"names":["schema","schemaOptions","resolverOptions","values","_","options","validateAllFieldCriteria","shouldUseNativeValidation","criteriaMode","Promise","resolve","safeParseAsync","Object","assign","abortPipeEarly","then","result","issues","errors","length","issue","path","getDotPath","message","type","types","messages","appendErrors","concat","shift","toNestErrors","raw","output","e","reject"],"mappings":"+GAME,SAACA,EAAQC,EAAeC,GACjBC,YADgC,IAAfD,IAAAA,EAAkB,CAAE,GACrCC,SAAAA,EAAQC,EAAGC,GAAO,IAEvB,IAAMC,GACHD,EAAQE,2BAAsD,QAAzBF,EAAQG,aAAuB,OAAAC,QAAAC,QAGlDC,EAAcA,eACjCX,EACAG,EACAS,OAAOC,OAAO,GAAIZ,EAAe,CAC/Ba,gBAAiBR,MAEpBS,KAAA,SANKC,GASN,GAAIA,EAAOC,OAAQ,CAKjB,IAHA,IAAMC,EAAqC,CAAA,EAGpCF,EAAOC,OAAOE,QAAU,CAC7B,IAAMC,EAAQJ,EAAOC,OAAO,GAEtBI,EAAOC,EAAUA,WAACF,GAExB,GAAIC,IAEGH,EAAOG,KACVH,EAAOG,GAAQ,CAAEE,QAASH,EAAMG,QAASC,KAAMJ,EAAMI,OAInDlB,GAA0B,CAC5B,IAAMmB,EAAQP,EAAOG,GAAMI,MACrBC,EAAWD,GAASA,EAAML,EAAMI,MACtCN,EAAOG,GAAQM,eACbN,EACAf,EACAY,EACAE,EAAMI,KACNE,EACK,GAAgBE,OACfF,EACAN,EAAMG,SAERH,EAAMG,QAEd,CAGFP,EAAOC,OAAOY,OAChB,CAGA,MAAO,CACL1B,OAAQ,CAAA,EACRe,OAAQY,EAAAA,aAAaZ,EAAQb,GAEjC,CAGA,MAAO,CACLF,OAAQD,EAAgB6B,IAAM5B,EAAUa,EAAOgB,OAC/Cd,OAAQ,CAAA,EACR,EACJ,CAAC,MAAAe,GAAAxB,OAAAA,QAAAyB,OAAAD,EAAA,CAAA,CAAA"}
|
||||
2
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.mjs
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.mjs
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import{toNestErrors as e}from"@hookform/resolvers";import{appendErrors as r}from"react-hook-form";import{safeParseAsync as s,getDotPath as t}from"valibot";var o=function(o,a,i){return void 0===i&&(i={}),function(u,n,m){try{var f=!m.shouldUseNativeValidation&&"all"===m.criteriaMode;return Promise.resolve(s(o,u,Object.assign({},a,{abortPipeEarly:!f}))).then(function(s){if(s.issues){for(var o={};s.issues.length;){var a=s.issues[0],n=t(a);if(n&&(o[n]||(o[n]={message:a.message,type:a.type}),f)){var v=o[n].types,c=v&&v[a.type];o[n]=r(n,f,o,a.type,c?[].concat(c,a.message):a.message)}s.issues.shift()}return{values:{},errors:e(o,m)}}return{values:i.raw?u:s.output,errors:{}}})}catch(e){return Promise.reject(e)}}};export{o as valibotResolver};
|
||||
//# sourceMappingURL=valibot.module.js.map
|
||||
2
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.modern.mjs
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.modern.mjs
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import{toNestErrors as s}from"@hookform/resolvers";import{appendErrors as e}from"react-hook-form";import{safeParseAsync as o,getDotPath as t}from"valibot";const r=(r,a,i={})=>async(m,n,c)=>{const p=!c.shouldUseNativeValidation&&"all"===c.criteriaMode,u=await o(r,m,Object.assign({},a,{abortPipeEarly:!p}));if(u.issues){const o={};for(;u.issues.length;){const s=u.issues[0],r=t(s);if(r&&(o[r]||(o[r]={message:s.message,type:s.type}),p)){const t=o[r].types,a=t&&t[s.type];o[r]=e(r,p,o,s.type,a?[].concat(a,s.message):s.message)}u.issues.shift()}return{values:{},errors:s(o,c)}}return{values:i.raw?m:u.output,errors:{}}};export{r as valibotResolver};
|
||||
//# sourceMappingURL=valibot.modern.mjs.map
|
||||
1
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.modern.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.modern.mjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"valibot.modern.mjs","sources":["../src/valibot.ts"],"sourcesContent":["import { toNestErrors } from '@hookform/resolvers';\nimport { FieldError, FieldValues, appendErrors } from 'react-hook-form';\nimport { getDotPath, safeParseAsync } from 'valibot';\nimport type { Resolver } from './types';\n\nexport const valibotResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n async (values, _, options) => {\n // Check if we should validate all field criteria\n const validateAllFieldCriteria =\n !options.shouldUseNativeValidation && options.criteriaMode === 'all';\n\n // Parse values with Valibot schema\n const result = await safeParseAsync(\n schema,\n values,\n Object.assign({}, schemaOptions, {\n abortPipeEarly: !validateAllFieldCriteria,\n }),\n );\n\n // If there are issues, return them as errors\n if (result.issues) {\n // Create errors object\n const errors: Record<string, FieldError> = {};\n\n // Iterate over issues to add them to errors object\n for (; result.issues.length; ) {\n const issue = result.issues[0];\n // Create dot path from issue\n const path = getDotPath(issue);\n\n if (path) {\n // Add first error of path to errors object\n if (!errors[path]) {\n errors[path] = { message: issue.message, type: issue.type };\n }\n\n // If configured, add all errors of path to errors object\n if (validateAllFieldCriteria) {\n const types = errors[path].types;\n const messages = types && types[issue.type];\n errors[path] = appendErrors(\n path,\n validateAllFieldCriteria,\n errors,\n issue.type,\n messages\n ? ([] as string[]).concat(\n messages as string | string[],\n issue.message,\n )\n : issue.message,\n ) as FieldError;\n }\n }\n\n result.issues.shift();\n }\n\n // Return resolver result with errors\n return {\n values: {},\n errors: toNestErrors(errors, options),\n } as const;\n }\n\n // Otherwise, return resolver result with values\n return {\n values: resolverOptions.raw ? values : (result.output as FieldValues),\n errors: {},\n };\n };\n"],"names":["valibotResolver","schema","schemaOptions","resolverOptions","async","values","_","options","validateAllFieldCriteria","shouldUseNativeValidation","criteriaMode","result","safeParseAsync","Object","assign","abortPipeEarly","issues","errors","length","issue","path","getDotPath","message","type","types","messages","appendErrors","concat","shift","toNestErrors","raw","output"],"mappings":"2JAKa,MAAAA,EACXA,CAACC,EAAQC,EAAeC,EAAkB,CAAA,IAC1CC,MAAOC,EAAQC,EAAGC,KAEhB,MAAMC,GACHD,EAAQE,2BAAsD,QAAzBF,EAAQG,aAG1CC,QAAeC,EACnBX,EACAI,EACAQ,OAAOC,OAAO,CAAA,EAAIZ,EAAe,CAC/Ba,gBAAiBP,KAKrB,GAAIG,EAAOK,OAAQ,CAEjB,MAAMC,EAAqC,CAAA,EAG3C,KAAON,EAAOK,OAAOE,QAAU,CAC7B,MAAMC,EAAQR,EAAOK,OAAO,GAEtBI,EAAOC,EAAWF,GAExB,GAAIC,IAEGH,EAAOG,KACVH,EAAOG,GAAQ,CAAEE,QAASH,EAAMG,QAASC,KAAMJ,EAAMI,OAInDf,GAA0B,CAC5B,MAAMgB,EAAQP,EAAOG,GAAMI,MACrBC,EAAWD,GAASA,EAAML,EAAMI,MACtCN,EAAOG,GAAQM,EACbN,EACAZ,EACAS,EACAE,EAAMI,KACNE,EACK,GAAgBE,OACfF,EACAN,EAAMG,SAERH,EAAMG,QAEd,CAGFX,EAAOK,OAAOY,OAChB,CAGA,MAAO,CACLvB,OAAQ,CAAA,EACRY,OAAQY,EAAaZ,EAAQV,GAEjC,CAGA,MAAO,CACLF,OAAQF,EAAgB2B,IAAMzB,EAAUM,EAAOoB,OAC/Cd,OAAQ,CAAA"}
|
||||
2
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.module.js
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.module.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import{toNestErrors as e}from"@hookform/resolvers";import{appendErrors as r}from"react-hook-form";import{safeParseAsync as s,getDotPath as t}from"valibot";var o=function(o,a,i){return void 0===i&&(i={}),function(u,n,m){try{var f=!m.shouldUseNativeValidation&&"all"===m.criteriaMode;return Promise.resolve(s(o,u,Object.assign({},a,{abortPipeEarly:!f}))).then(function(s){if(s.issues){for(var o={};s.issues.length;){var a=s.issues[0],n=t(a);if(n&&(o[n]||(o[n]={message:a.message,type:a.type}),f)){var v=o[n].types,c=v&&v[a.type];o[n]=r(n,f,o,a.type,c?[].concat(c,a.message):a.message)}s.issues.shift()}return{values:{},errors:e(o,m)}}return{values:i.raw?u:s.output,errors:{}}})}catch(e){return Promise.reject(e)}}};export{o as valibotResolver};
|
||||
//# sourceMappingURL=valibot.module.js.map
|
||||
1
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.module.js.map
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.module.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"valibot.module.js","sources":["../src/valibot.ts"],"sourcesContent":["import { toNestErrors } from '@hookform/resolvers';\nimport { FieldError, FieldValues, appendErrors } from 'react-hook-form';\nimport { getDotPath, safeParseAsync } from 'valibot';\nimport type { Resolver } from './types';\n\nexport const valibotResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n async (values, _, options) => {\n // Check if we should validate all field criteria\n const validateAllFieldCriteria =\n !options.shouldUseNativeValidation && options.criteriaMode === 'all';\n\n // Parse values with Valibot schema\n const result = await safeParseAsync(\n schema,\n values,\n Object.assign({}, schemaOptions, {\n abortPipeEarly: !validateAllFieldCriteria,\n }),\n );\n\n // If there are issues, return them as errors\n if (result.issues) {\n // Create errors object\n const errors: Record<string, FieldError> = {};\n\n // Iterate over issues to add them to errors object\n for (; result.issues.length; ) {\n const issue = result.issues[0];\n // Create dot path from issue\n const path = getDotPath(issue);\n\n if (path) {\n // Add first error of path to errors object\n if (!errors[path]) {\n errors[path] = { message: issue.message, type: issue.type };\n }\n\n // If configured, add all errors of path to errors object\n if (validateAllFieldCriteria) {\n const types = errors[path].types;\n const messages = types && types[issue.type];\n errors[path] = appendErrors(\n path,\n validateAllFieldCriteria,\n errors,\n issue.type,\n messages\n ? ([] as string[]).concat(\n messages as string | string[],\n issue.message,\n )\n : issue.message,\n ) as FieldError;\n }\n }\n\n result.issues.shift();\n }\n\n // Return resolver result with errors\n return {\n values: {},\n errors: toNestErrors(errors, options),\n } as const;\n }\n\n // Otherwise, return resolver result with values\n return {\n values: resolverOptions.raw ? values : (result.output as FieldValues),\n errors: {},\n };\n };\n"],"names":["valibotResolver","schema","schemaOptions","resolverOptions","values","_","options","validateAllFieldCriteria","shouldUseNativeValidation","criteriaMode","Promise","resolve","safeParseAsync","Object","assign","abortPipeEarly","then","result","issues","errors","length","issue","path","getDotPath","message","type","types","messages","appendErrors","concat","shift","toNestErrors","raw","output","e","reject"],"mappings":"2JAKa,IAAAA,EACX,SAACC,EAAQC,EAAeC,GACjBC,YADgC,IAAfD,IAAAA,EAAkB,CAAE,GACrCC,SAAAA,EAAQC,EAAGC,GAAO,IAEvB,IAAMC,GACHD,EAAQE,2BAAsD,QAAzBF,EAAQG,aAAuB,OAAAC,QAAAC,QAGlDC,EACnBX,EACAG,EACAS,OAAOC,OAAO,GAAIZ,EAAe,CAC/Ba,gBAAiBR,MAEpBS,KAAA,SANKC,GASN,GAAIA,EAAOC,OAAQ,CAKjB,IAHA,IAAMC,EAAqC,CAAA,EAGpCF,EAAOC,OAAOE,QAAU,CAC7B,IAAMC,EAAQJ,EAAOC,OAAO,GAEtBI,EAAOC,EAAWF,GAExB,GAAIC,IAEGH,EAAOG,KACVH,EAAOG,GAAQ,CAAEE,QAASH,EAAMG,QAASC,KAAMJ,EAAMI,OAInDlB,GAA0B,CAC5B,IAAMmB,EAAQP,EAAOG,GAAMI,MACrBC,EAAWD,GAASA,EAAML,EAAMI,MACtCN,EAAOG,GAAQM,EACbN,EACAf,EACAY,EACAE,EAAMI,KACNE,EACK,GAAgBE,OACfF,EACAN,EAAMG,SAERH,EAAMG,QAEd,CAGFP,EAAOC,OAAOY,OAChB,CAGA,MAAO,CACL1B,OAAQ,CAAA,EACRe,OAAQY,EAAaZ,EAAQb,GAEjC,CAGA,MAAO,CACLF,OAAQD,EAAgB6B,IAAM5B,EAAUa,EAAOgB,OAC/Cd,OAAQ,CAAA,EACR,EACJ,CAAC,MAAAe,GAAAxB,OAAAA,QAAAyB,OAAAD,EAAA,CAAA,CAAA"}
|
||||
2
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.umd.js
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.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"),require("valibot")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","react-hook-form","valibot"],o):o((e||self).hookformResolversValibot={},e.hookformResolvers,e.ReactHookForm,e.valibot)}(this,function(e,o,r,s){e.valibotResolver=function(e,t,i){return void 0===i&&(i={}),function(a,n,f){try{var u=!f.shouldUseNativeValidation&&"all"===f.criteriaMode;return Promise.resolve(s.safeParseAsync(e,a,Object.assign({},t,{abortPipeEarly:!u}))).then(function(e){if(e.issues){for(var t={};e.issues.length;){var n=e.issues[0],l=s.getDotPath(n);if(l&&(t[l]||(t[l]={message:n.message,type:n.type}),u)){var c=t[l].types,v=c&&c[n.type];t[l]=r.appendErrors(l,u,t,n.type,v?[].concat(v,n.message):n.message)}e.issues.shift()}return{values:{},errors:o.toNestErrors(t,f)}}return{values:i.raw?a:e.output,errors:{}}})}catch(e){return Promise.reject(e)}}}});
|
||||
//# sourceMappingURL=valibot.umd.js.map
|
||||
1
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.umd.js.map
generated
vendored
Normal file
1
frontend/node_modules/@hookform/resolvers/valibot/dist/valibot.umd.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"valibot.umd.js","sources":["../src/valibot.ts"],"sourcesContent":["import { toNestErrors } from '@hookform/resolvers';\nimport { FieldError, FieldValues, appendErrors } from 'react-hook-form';\nimport { getDotPath, safeParseAsync } from 'valibot';\nimport type { Resolver } from './types';\n\nexport const valibotResolver: Resolver =\n (schema, schemaOptions, resolverOptions = {}) =>\n async (values, _, options) => {\n // Check if we should validate all field criteria\n const validateAllFieldCriteria =\n !options.shouldUseNativeValidation && options.criteriaMode === 'all';\n\n // Parse values with Valibot schema\n const result = await safeParseAsync(\n schema,\n values,\n Object.assign({}, schemaOptions, {\n abortPipeEarly: !validateAllFieldCriteria,\n }),\n );\n\n // If there are issues, return them as errors\n if (result.issues) {\n // Create errors object\n const errors: Record<string, FieldError> = {};\n\n // Iterate over issues to add them to errors object\n for (; result.issues.length; ) {\n const issue = result.issues[0];\n // Create dot path from issue\n const path = getDotPath(issue);\n\n if (path) {\n // Add first error of path to errors object\n if (!errors[path]) {\n errors[path] = { message: issue.message, type: issue.type };\n }\n\n // If configured, add all errors of path to errors object\n if (validateAllFieldCriteria) {\n const types = errors[path].types;\n const messages = types && types[issue.type];\n errors[path] = appendErrors(\n path,\n validateAllFieldCriteria,\n errors,\n issue.type,\n messages\n ? ([] as string[]).concat(\n messages as string | string[],\n issue.message,\n )\n : issue.message,\n ) as FieldError;\n }\n }\n\n result.issues.shift();\n }\n\n // Return resolver result with errors\n return {\n values: {},\n errors: toNestErrors(errors, options),\n } as const;\n }\n\n // Otherwise, return resolver result with values\n return {\n values: resolverOptions.raw ? values : (result.output as FieldValues),\n errors: {},\n };\n };\n"],"names":["schema","schemaOptions","resolverOptions","values","_","options","validateAllFieldCriteria","shouldUseNativeValidation","criteriaMode","Promise","resolve","safeParseAsync","Object","assign","abortPipeEarly","then","result","issues","errors","length","issue","path","getDotPath","message","type","types","messages","appendErrors","concat","shift","toNestErrors","raw","output","e","reject"],"mappings":"ubAME,SAACA,EAAQC,EAAeC,GACjBC,YADgC,IAAfD,IAAAA,EAAkB,CAAE,GACrCC,SAAAA,EAAQC,EAAGC,GAAO,IAEvB,IAAMC,GACHD,EAAQE,2BAAsD,QAAzBF,EAAQG,aAAuB,OAAAC,QAAAC,QAGlDC,EAAcA,eACjCX,EACAG,EACAS,OAAOC,OAAO,GAAIZ,EAAe,CAC/Ba,gBAAiBR,MAEpBS,KAAA,SANKC,GASN,GAAIA,EAAOC,OAAQ,CAKjB,IAHA,IAAMC,EAAqC,CAAA,EAGpCF,EAAOC,OAAOE,QAAU,CAC7B,IAAMC,EAAQJ,EAAOC,OAAO,GAEtBI,EAAOC,EAAUA,WAACF,GAExB,GAAIC,IAEGH,EAAOG,KACVH,EAAOG,GAAQ,CAAEE,QAASH,EAAMG,QAASC,KAAMJ,EAAMI,OAInDlB,GAA0B,CAC5B,IAAMmB,EAAQP,EAAOG,GAAMI,MACrBC,EAAWD,GAASA,EAAML,EAAMI,MACtCN,EAAOG,GAAQM,eACbN,EACAf,EACAY,EACAE,EAAMI,KACNE,EACK,GAAgBE,OACfF,EACAN,EAAMG,SAERH,EAAMG,QAEd,CAGFP,EAAOC,OAAOY,OAChB,CAGA,MAAO,CACL1B,OAAQ,CAAA,EACRe,OAAQY,EAAAA,aAAaZ,EAAQb,GAEjC,CAGA,MAAO,CACLF,OAAQD,EAAgB6B,IAAM5B,EAAUa,EAAOgB,OAC/Cd,OAAQ,CAAA,EACR,EACJ,CAAC,MAAAe,GAAAxB,OAAAA,QAAAyB,OAAAD,EAAA,CAAA,CAAA"}
|
||||
18
frontend/node_modules/@hookform/resolvers/valibot/package.json
generated
vendored
Normal file
18
frontend/node_modules/@hookform/resolvers/valibot/package.json
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "@hookform/resolvers/valibot",
|
||||
"amdName": "hookformResolversValibot",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "React Hook Form validation resolver: valibot",
|
||||
"main": "dist/valibot.js",
|
||||
"module": "dist/valibot.module.js",
|
||||
"umd:main": "dist/valibot.umd.js",
|
||||
"source": "src/index.ts",
|
||||
"types": "dist/index.d.ts",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@hookform/resolvers": "^2.0.0",
|
||||
"react-hook-form": "^7.0.0",
|
||||
"valibot": "^1.0.0 || ^1.0.0-beta || ^1.0.0-rc"
|
||||
}
|
||||
}
|
||||
81
frontend/node_modules/@hookform/resolvers/valibot/src/__tests__/Form-native-validation.tsx
generated
vendored
Normal file
81
frontend/node_modules/@hookform/resolvers/valibot/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 v from 'valibot';
|
||||
import { valibotResolver } from '..';
|
||||
|
||||
const USERNAME_REQUIRED_MESSAGE = 'username field is v.required';
|
||||
const PASSWORD_REQUIRED_MESSAGE = 'password field is v.required';
|
||||
|
||||
const schema = v.object({
|
||||
username: v.pipe(
|
||||
v.string(USERNAME_REQUIRED_MESSAGE),
|
||||
v.minLength(2, USERNAME_REQUIRED_MESSAGE),
|
||||
),
|
||||
password: v.pipe(
|
||||
v.string(PASSWORD_REQUIRED_MESSAGE),
|
||||
v.minLength(2, PASSWORD_REQUIRED_MESSAGE),
|
||||
),
|
||||
});
|
||||
|
||||
type FormData = { username: string; password: string };
|
||||
|
||||
interface Props {
|
||||
onSubmit: (data: FormData) => void;
|
||||
}
|
||||
|
||||
function TestComponent({ onSubmit }: Props) {
|
||||
const { register, handleSubmit } = useForm<FormData>({
|
||||
resolver: valibotResolver(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 Valibot", 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(/password/i), 'password');
|
||||
|
||||
// password
|
||||
passwordField = screen.getByPlaceholderText(/password/i) as HTMLInputElement;
|
||||
expect(passwordField.validity.valid).toBe(true);
|
||||
expect(passwordField.validationMessage).toBe('');
|
||||
});
|
||||
61
frontend/node_modules/@hookform/resolvers/valibot/src/__tests__/Form.tsx
generated
vendored
Normal file
61
frontend/node_modules/@hookform/resolvers/valibot/src/__tests__/Form.tsx
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
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 v from 'valibot';
|
||||
import { valibotResolver } from '..';
|
||||
|
||||
const USERNAME_REQUIRED_MESSAGE = 'username field is required';
|
||||
const PASSWORD_REQUIRED_MESSAGE = 'password field is required';
|
||||
|
||||
const schema = v.object({
|
||||
username: v.pipe(
|
||||
v.string(USERNAME_REQUIRED_MESSAGE),
|
||||
v.minLength(2, USERNAME_REQUIRED_MESSAGE),
|
||||
),
|
||||
password: v.pipe(
|
||||
v.string(PASSWORD_REQUIRED_MESSAGE),
|
||||
v.minLength(2, PASSWORD_REQUIRED_MESSAGE),
|
||||
),
|
||||
});
|
||||
|
||||
type FormData = { username: string; password: string };
|
||||
|
||||
interface Props {
|
||||
onSubmit: (data: FormData) => void;
|
||||
}
|
||||
|
||||
function TestComponent({ onSubmit }: Props) {
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm<FormData>({
|
||||
resolver: valibotResolver(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 Valibot 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();
|
||||
});
|
||||
95
frontend/node_modules/@hookform/resolvers/valibot/src/__tests__/__fixtures__/data.ts
generated
vendored
Normal file
95
frontend/node_modules/@hookform/resolvers/valibot/src/__tests__/__fixtures__/data.ts
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
import { Field, InternalFieldName } from 'react-hook-form';
|
||||
import * as v from 'valibot';
|
||||
|
||||
export const schema = v.object({
|
||||
username: v.pipe(
|
||||
v.string(),
|
||||
v.minLength(2),
|
||||
v.maxLength(30),
|
||||
v.regex(/^\w+$/),
|
||||
),
|
||||
password: v.pipe(
|
||||
v.string('New Password is required'),
|
||||
v.regex(new RegExp('.*[A-Z].*'), 'One uppercase character'),
|
||||
v.regex(new RegExp('.*[a-z].*'), 'One lowercase character'),
|
||||
v.regex(new RegExp('.*\\d.*'), 'One number'),
|
||||
v.regex(
|
||||
new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'),
|
||||
'One special character',
|
||||
),
|
||||
v.minLength(8, 'Must be at least 8 characters in length'),
|
||||
),
|
||||
repeatPassword: v.string('Repeat Password is required'),
|
||||
accessToken: v.union(
|
||||
[
|
||||
v.string('Access token should be a string'),
|
||||
v.number('Access token should be a number'),
|
||||
],
|
||||
'access token is required',
|
||||
),
|
||||
birthYear: v.pipe(
|
||||
v.number('Please enter your birth year'),
|
||||
v.minValue(1900),
|
||||
v.maxValue(2013),
|
||||
),
|
||||
email: v.pipe(v.string(), v.email('Invalid email address')),
|
||||
tags: v.array(v.string('Tags should be strings')),
|
||||
enabled: v.boolean(),
|
||||
like: v.object({
|
||||
id: v.number('Like id is required'),
|
||||
name: v.pipe(
|
||||
v.string('Like name is required'),
|
||||
v.minLength(4, 'Too short'),
|
||||
),
|
||||
}),
|
||||
});
|
||||
|
||||
export const schemaError = v.variant('type', [
|
||||
v.object({ type: v.literal('a') }),
|
||||
v.object({ type: v.literal('b') }),
|
||||
]);
|
||||
|
||||
export const validSchemaErrorData = { type: 'a' };
|
||||
export const invalidSchemaErrorData = { type: 'c' };
|
||||
|
||||
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',
|
||||
},
|
||||
};
|
||||
|
||||
export const invalidData = {
|
||||
password: '___',
|
||||
email: '',
|
||||
birthYear: 'birthYear',
|
||||
like: { id: 'z' },
|
||||
tags: [1, 2, 3],
|
||||
};
|
||||
|
||||
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',
|
||||
},
|
||||
};
|
||||
418
frontend/node_modules/@hookform/resolvers/valibot/src/__tests__/__snapshots__/valibot.ts.snap
generated
vendored
Normal file
418
frontend/node_modules/@hookform/resolvers/valibot/src/__tests__/__snapshots__/valibot.ts.snap
generated
vendored
Normal file
@ -0,0 +1,418 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`valibotResolver > should return a single error from valibotResolver when validation fails 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"accessToken": {
|
||||
"message": "access token is required",
|
||||
"ref": undefined,
|
||||
"type": "union",
|
||||
},
|
||||
"birthYear": {
|
||||
"message": "Please enter your birth year",
|
||||
"ref": undefined,
|
||||
"type": "number",
|
||||
},
|
||||
"email": {
|
||||
"message": "Invalid email address",
|
||||
"ref": {
|
||||
"name": "email",
|
||||
},
|
||||
"type": "email",
|
||||
},
|
||||
"enabled": {
|
||||
"message": "Invalid type: Expected boolean but received undefined",
|
||||
"ref": undefined,
|
||||
"type": "boolean",
|
||||
},
|
||||
"like": {
|
||||
"id": {
|
||||
"message": "Like id is required",
|
||||
"ref": undefined,
|
||||
"type": "number",
|
||||
},
|
||||
"name": {
|
||||
"message": "Like name is required",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
"password": {
|
||||
"message": "One uppercase character",
|
||||
"ref": {
|
||||
"name": "password",
|
||||
},
|
||||
"type": "regex",
|
||||
},
|
||||
"repeatPassword": {
|
||||
"message": "Repeat Password is required",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"message": "Tags should be strings",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
},
|
||||
{
|
||||
"message": "Tags should be strings",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
},
|
||||
{
|
||||
"message": "Tags should be strings",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
},
|
||||
],
|
||||
"username": {
|
||||
"message": "Invalid type: Expected string but received undefined",
|
||||
"ref": {
|
||||
"name": "username",
|
||||
},
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`valibotResolver > should return a single error from valibotResolver with \`mode: sync\` when validation fails 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"accessToken": {
|
||||
"message": "access token is required",
|
||||
"ref": undefined,
|
||||
"type": "union",
|
||||
},
|
||||
"birthYear": {
|
||||
"message": "Please enter your birth year",
|
||||
"ref": undefined,
|
||||
"type": "number",
|
||||
},
|
||||
"email": {
|
||||
"message": "Invalid email address",
|
||||
"ref": {
|
||||
"name": "email",
|
||||
},
|
||||
"type": "email",
|
||||
},
|
||||
"enabled": {
|
||||
"message": "Invalid type: Expected boolean but received undefined",
|
||||
"ref": undefined,
|
||||
"type": "boolean",
|
||||
},
|
||||
"like": {
|
||||
"id": {
|
||||
"message": "Like id is required",
|
||||
"ref": undefined,
|
||||
"type": "number",
|
||||
},
|
||||
"name": {
|
||||
"message": "Like name is required",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
"password": {
|
||||
"message": "One uppercase character",
|
||||
"ref": {
|
||||
"name": "password",
|
||||
},
|
||||
"type": "regex",
|
||||
},
|
||||
"repeatPassword": {
|
||||
"message": "Repeat Password is required",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"message": "Tags should be strings",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
},
|
||||
{
|
||||
"message": "Tags should be strings",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
},
|
||||
{
|
||||
"message": "Tags should be strings",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
},
|
||||
],
|
||||
"username": {
|
||||
"message": "Invalid type: Expected string but received undefined",
|
||||
"ref": {
|
||||
"name": "username",
|
||||
},
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`valibotResolver > should return all the errors from valibotResolver when validation fails with \`validateAllFieldCriteria\` set to true 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"accessToken": {
|
||||
"message": "access token is required",
|
||||
"ref": undefined,
|
||||
"type": "union",
|
||||
"types": {
|
||||
"union": "access token is required",
|
||||
},
|
||||
},
|
||||
"birthYear": {
|
||||
"message": "Please enter your birth year",
|
||||
"ref": undefined,
|
||||
"type": "number",
|
||||
"types": {
|
||||
"number": "Please enter your birth year",
|
||||
},
|
||||
},
|
||||
"email": {
|
||||
"message": "Invalid email address",
|
||||
"ref": {
|
||||
"name": "email",
|
||||
},
|
||||
"type": "email",
|
||||
"types": {
|
||||
"email": "Invalid email address",
|
||||
},
|
||||
},
|
||||
"enabled": {
|
||||
"message": "Invalid type: Expected boolean but received undefined",
|
||||
"ref": undefined,
|
||||
"type": "boolean",
|
||||
"types": {
|
||||
"boolean": "Invalid type: Expected boolean but received undefined",
|
||||
},
|
||||
},
|
||||
"like": {
|
||||
"id": {
|
||||
"message": "Like id is required",
|
||||
"ref": undefined,
|
||||
"type": "number",
|
||||
"types": {
|
||||
"number": "Like id is required",
|
||||
},
|
||||
},
|
||||
"name": {
|
||||
"message": "Like name is required",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
"types": {
|
||||
"string": "Like name is required",
|
||||
},
|
||||
},
|
||||
},
|
||||
"password": {
|
||||
"message": "One uppercase character",
|
||||
"ref": {
|
||||
"name": "password",
|
||||
},
|
||||
"type": "regex",
|
||||
"types": {
|
||||
"min_length": "Must be at least 8 characters in length",
|
||||
"regex": [
|
||||
"One uppercase character",
|
||||
"One lowercase character",
|
||||
"One number",
|
||||
],
|
||||
},
|
||||
},
|
||||
"repeatPassword": {
|
||||
"message": "Repeat Password is required",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
"types": {
|
||||
"string": "Repeat Password is required",
|
||||
},
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"message": "Tags should be strings",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
"types": {
|
||||
"string": "Tags should be strings",
|
||||
},
|
||||
},
|
||||
{
|
||||
"message": "Tags should be strings",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
"types": {
|
||||
"string": "Tags should be strings",
|
||||
},
|
||||
},
|
||||
{
|
||||
"message": "Tags should be strings",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
"types": {
|
||||
"string": "Tags should be strings",
|
||||
},
|
||||
},
|
||||
],
|
||||
"username": {
|
||||
"message": "Invalid type: Expected string but received undefined",
|
||||
"ref": {
|
||||
"name": "username",
|
||||
},
|
||||
"type": "string",
|
||||
"types": {
|
||||
"string": "Invalid type: Expected string but received undefined",
|
||||
},
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`valibotResolver > should return all the errors from valibotResolver when validation fails with \`validateAllFieldCriteria\` set to true and \`mode: sync\` 1`] = `
|
||||
{
|
||||
"errors": {
|
||||
"accessToken": {
|
||||
"message": "access token is required",
|
||||
"ref": undefined,
|
||||
"type": "union",
|
||||
"types": {
|
||||
"union": "access token is required",
|
||||
},
|
||||
},
|
||||
"birthYear": {
|
||||
"message": "Please enter your birth year",
|
||||
"ref": undefined,
|
||||
"type": "number",
|
||||
"types": {
|
||||
"number": "Please enter your birth year",
|
||||
},
|
||||
},
|
||||
"email": {
|
||||
"message": "Invalid email address",
|
||||
"ref": {
|
||||
"name": "email",
|
||||
},
|
||||
"type": "email",
|
||||
"types": {
|
||||
"email": "Invalid email address",
|
||||
},
|
||||
},
|
||||
"enabled": {
|
||||
"message": "Invalid type: Expected boolean but received undefined",
|
||||
"ref": undefined,
|
||||
"type": "boolean",
|
||||
"types": {
|
||||
"boolean": "Invalid type: Expected boolean but received undefined",
|
||||
},
|
||||
},
|
||||
"like": {
|
||||
"id": {
|
||||
"message": "Like id is required",
|
||||
"ref": undefined,
|
||||
"type": "number",
|
||||
"types": {
|
||||
"number": "Like id is required",
|
||||
},
|
||||
},
|
||||
"name": {
|
||||
"message": "Like name is required",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
"types": {
|
||||
"string": "Like name is required",
|
||||
},
|
||||
},
|
||||
},
|
||||
"password": {
|
||||
"message": "One uppercase character",
|
||||
"ref": {
|
||||
"name": "password",
|
||||
},
|
||||
"type": "regex",
|
||||
"types": {
|
||||
"min_length": "Must be at least 8 characters in length",
|
||||
"regex": [
|
||||
"One uppercase character",
|
||||
"One lowercase character",
|
||||
"One number",
|
||||
],
|
||||
},
|
||||
},
|
||||
"repeatPassword": {
|
||||
"message": "Repeat Password is required",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
"types": {
|
||||
"string": "Repeat Password is required",
|
||||
},
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"message": "Tags should be strings",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
"types": {
|
||||
"string": "Tags should be strings",
|
||||
},
|
||||
},
|
||||
{
|
||||
"message": "Tags should be strings",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
"types": {
|
||||
"string": "Tags should be strings",
|
||||
},
|
||||
},
|
||||
{
|
||||
"message": "Tags should be strings",
|
||||
"ref": undefined,
|
||||
"type": "string",
|
||||
"types": {
|
||||
"string": "Tags should be strings",
|
||||
},
|
||||
},
|
||||
],
|
||||
"username": {
|
||||
"message": "Invalid type: Expected string but received undefined",
|
||||
"ref": {
|
||||
"name": "username",
|
||||
},
|
||||
"type": "string",
|
||||
"types": {
|
||||
"string": "Invalid type: Expected string but received undefined",
|
||||
},
|
||||
},
|
||||
},
|
||||
"values": {},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`valibotResolver > should return parsed values from valibotResolver with \`mode: sync\` when validation pass 1`] = `
|
||||
{
|
||||
"errors": {},
|
||||
"values": {
|
||||
"accessToken": "accessToken",
|
||||
"birthYear": 2000,
|
||||
"email": "john@doe.com",
|
||||
"enabled": true,
|
||||
"like": {
|
||||
"id": 1,
|
||||
"name": "name",
|
||||
},
|
||||
"password": "Password123_",
|
||||
"repeatPassword": "Password123_",
|
||||
"tags": [
|
||||
"tag1",
|
||||
"tag2",
|
||||
],
|
||||
"username": "Doe",
|
||||
},
|
||||
}
|
||||
`;
|
||||
141
frontend/node_modules/@hookform/resolvers/valibot/src/__tests__/valibot.ts
generated
vendored
Normal file
141
frontend/node_modules/@hookform/resolvers/valibot/src/__tests__/valibot.ts
generated
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
import * as valibot from 'valibot';
|
||||
/* eslint-disable no-console, @typescript-eslint/ban-ts-comment */
|
||||
import { valibotResolver } from '..';
|
||||
import {
|
||||
fields,
|
||||
invalidData,
|
||||
invalidSchemaErrorData,
|
||||
schema,
|
||||
schemaError,
|
||||
validData,
|
||||
validSchemaErrorData,
|
||||
} from './__fixtures__/data';
|
||||
|
||||
const shouldUseNativeValidation = false;
|
||||
describe('valibotResolver', () => {
|
||||
it('should return parsed values from valibotResolver with `mode: sync` when validation pass', async () => {
|
||||
vi.mock('valibot', async () => {
|
||||
const a = await vi.importActual<any>('valibot');
|
||||
return {
|
||||
__esModule: true,
|
||||
...a,
|
||||
};
|
||||
});
|
||||
const funcSpy = vi.spyOn(valibot, 'safeParseAsync');
|
||||
|
||||
const result = await valibotResolver(schema, undefined, {
|
||||
mode: 'sync',
|
||||
})(validData, undefined, { fields, shouldUseNativeValidation });
|
||||
|
||||
expect(funcSpy).toHaveBeenCalledTimes(1);
|
||||
expect(result.errors).toEqual({});
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return a single error from valibotResolver with `mode: sync` when validation fails', async () => {
|
||||
vi.mock('valibot', async () => {
|
||||
const a = await vi.importActual<any>('valibot');
|
||||
return {
|
||||
__esModule: true,
|
||||
...a,
|
||||
};
|
||||
});
|
||||
const funcSpy = vi.spyOn(valibot, 'safeParseAsync');
|
||||
|
||||
const result = await valibotResolver(schema, undefined, {
|
||||
mode: 'sync',
|
||||
})(invalidData, undefined, { fields, shouldUseNativeValidation });
|
||||
|
||||
expect(funcSpy).toHaveBeenCalledTimes(1);
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return values from valibotResolver when validation pass', async () => {
|
||||
const result = await valibotResolver(schema)(validData, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(result).toEqual({ errors: {}, values: validData });
|
||||
});
|
||||
|
||||
it('should return a single error from valibotResolver when validation fails', async () => {
|
||||
const result = await valibotResolver(schema)(invalidData, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return values from valibotResolver when validation pass & raw=true', async () => {
|
||||
const result = await valibotResolver(schema, undefined, {
|
||||
raw: true,
|
||||
})(validData, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(result).toEqual({ errors: {}, values: validData });
|
||||
});
|
||||
|
||||
it('should return all the errors from valibotResolver when validation fails with `validateAllFieldCriteria` set to true', async () => {
|
||||
const result = await valibotResolver(schema)(invalidData, undefined, {
|
||||
fields,
|
||||
criteriaMode: 'all',
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should return all the errors from valibotResolver when validation fails with `validateAllFieldCriteria` set to true and `mode: sync`', async () => {
|
||||
const result = await valibotResolver(schema, undefined, { mode: 'sync' })(
|
||||
invalidData,
|
||||
undefined,
|
||||
{
|
||||
fields,
|
||||
criteriaMode: 'all',
|
||||
shouldUseNativeValidation,
|
||||
},
|
||||
);
|
||||
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should be able to validate variants without errors', async () => {
|
||||
const result = await valibotResolver(schemaError, undefined, {
|
||||
mode: 'sync',
|
||||
})(validSchemaErrorData, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
errors: {},
|
||||
values: {
|
||||
type: 'a',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to validate variants with errors', async () => {
|
||||
const result = await valibotResolver(schemaError, undefined, {
|
||||
mode: 'sync',
|
||||
})(invalidSchemaErrorData, undefined, {
|
||||
fields,
|
||||
shouldUseNativeValidation,
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
errors: {
|
||||
type: {
|
||||
message: 'Invalid type: Expected "a" | "b" but received "c"',
|
||||
ref: undefined,
|
||||
type: 'variant',
|
||||
},
|
||||
},
|
||||
values: {},
|
||||
});
|
||||
});
|
||||
});
|
||||
2
frontend/node_modules/@hookform/resolvers/valibot/src/index.ts
generated
vendored
Normal file
2
frontend/node_modules/@hookform/resolvers/valibot/src/index.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './valibot';
|
||||
export * from './types';
|
||||
34
frontend/node_modules/@hookform/resolvers/valibot/src/types.ts
generated
vendored
Normal file
34
frontend/node_modules/@hookform/resolvers/valibot/src/types.ts
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
import { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
|
||||
import {
|
||||
BaseIssue,
|
||||
BaseSchema,
|
||||
BaseSchemaAsync,
|
||||
Config,
|
||||
InferIssue,
|
||||
} from 'valibot';
|
||||
|
||||
export type Resolver = <
|
||||
T extends
|
||||
| BaseSchema<unknown, unknown, BaseIssue<unknown>>
|
||||
| BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>,
|
||||
>(
|
||||
schema: T,
|
||||
schemaOptions?: Partial<
|
||||
Omit<Config<InferIssue<T>>, 'abortPipeEarly' | 'skipPipe'>
|
||||
>,
|
||||
resolverOptions?: {
|
||||
/**
|
||||
* @default async
|
||||
*/
|
||||
mode?: 'sync' | 'async';
|
||||
/**
|
||||
* 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>>;
|
||||
73
frontend/node_modules/@hookform/resolvers/valibot/src/valibot.ts
generated
vendored
Normal file
73
frontend/node_modules/@hookform/resolvers/valibot/src/valibot.ts
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
import { toNestErrors } from '@hookform/resolvers';
|
||||
import { FieldError, FieldValues, appendErrors } from 'react-hook-form';
|
||||
import { getDotPath, safeParseAsync } from 'valibot';
|
||||
import type { Resolver } from './types';
|
||||
|
||||
export const valibotResolver: Resolver =
|
||||
(schema, schemaOptions, resolverOptions = {}) =>
|
||||
async (values, _, options) => {
|
||||
// Check if we should validate all field criteria
|
||||
const validateAllFieldCriteria =
|
||||
!options.shouldUseNativeValidation && options.criteriaMode === 'all';
|
||||
|
||||
// Parse values with Valibot schema
|
||||
const result = await safeParseAsync(
|
||||
schema,
|
||||
values,
|
||||
Object.assign({}, schemaOptions, {
|
||||
abortPipeEarly: !validateAllFieldCriteria,
|
||||
}),
|
||||
);
|
||||
|
||||
// If there are issues, return them as errors
|
||||
if (result.issues) {
|
||||
// Create errors object
|
||||
const errors: Record<string, FieldError> = {};
|
||||
|
||||
// Iterate over issues to add them to errors object
|
||||
for (; result.issues.length; ) {
|
||||
const issue = result.issues[0];
|
||||
// Create dot path from issue
|
||||
const path = getDotPath(issue);
|
||||
|
||||
if (path) {
|
||||
// Add first error of path to errors object
|
||||
if (!errors[path]) {
|
||||
errors[path] = { message: issue.message, type: issue.type };
|
||||
}
|
||||
|
||||
// If configured, add all errors of path to errors object
|
||||
if (validateAllFieldCriteria) {
|
||||
const types = errors[path].types;
|
||||
const messages = types && types[issue.type];
|
||||
errors[path] = appendErrors(
|
||||
path,
|
||||
validateAllFieldCriteria,
|
||||
errors,
|
||||
issue.type,
|
||||
messages
|
||||
? ([] as string[]).concat(
|
||||
messages as string | string[],
|
||||
issue.message,
|
||||
)
|
||||
: issue.message,
|
||||
) as FieldError;
|
||||
}
|
||||
}
|
||||
|
||||
result.issues.shift();
|
||||
}
|
||||
|
||||
// Return resolver result with errors
|
||||
return {
|
||||
values: {},
|
||||
errors: toNestErrors(errors, options),
|
||||
} as const;
|
||||
}
|
||||
|
||||
// Otherwise, return resolver result with values
|
||||
return {
|
||||
values: resolverOptions.raw ? values : (result.output as FieldValues),
|
||||
errors: {},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user