@hookform/resolvers 2.0.0-beta.7 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +19 -10
  2. package/dist/index.d.ts +1 -1
  3. package/dist/resolvers.js +1 -1
  4. package/dist/resolvers.js.map +1 -1
  5. package/dist/resolvers.mjs +1 -1
  6. package/dist/resolvers.modern.js +1 -1
  7. package/dist/resolvers.modern.js.map +1 -1
  8. package/dist/resolvers.module.js +1 -1
  9. package/dist/resolvers.module.js.map +1 -1
  10. package/dist/resolvers.umd.js +1 -1
  11. package/dist/resolvers.umd.js.map +1 -1
  12. package/dist/toNestError.d.ts +2 -0
  13. package/joi/dist/joi.js +1 -1
  14. package/joi/dist/joi.js.map +1 -1
  15. package/joi/dist/joi.mjs +1 -1
  16. package/joi/dist/joi.modern.js +1 -1
  17. package/joi/dist/joi.modern.js.map +1 -1
  18. package/joi/dist/joi.module.js +1 -1
  19. package/joi/dist/joi.module.js.map +1 -1
  20. package/joi/dist/joi.umd.js +1 -1
  21. package/joi/dist/joi.umd.js.map +1 -1
  22. package/joi/dist/types.d.ts +1 -1
  23. package/joi/src/__tests__/__fixtures__/data.ts +76 -0
  24. package/joi/src/__tests__/__snapshots__/joi.ts.snap +118 -0
  25. package/joi/src/__tests__/joi.ts +35 -88
  26. package/joi/src/joi.ts +47 -64
  27. package/joi/src/types.ts +1 -1
  28. package/package.json +14 -15
  29. package/superstruct/dist/superstruct.js +1 -1
  30. package/superstruct/dist/superstruct.js.map +1 -1
  31. package/superstruct/dist/superstruct.mjs +1 -1
  32. package/superstruct/dist/superstruct.modern.js +1 -1
  33. package/superstruct/dist/superstruct.modern.js.map +1 -1
  34. package/superstruct/dist/superstruct.module.js +1 -1
  35. package/superstruct/dist/superstruct.module.js.map +1 -1
  36. package/superstruct/dist/superstruct.umd.js +1 -1
  37. package/superstruct/dist/superstruct.umd.js.map +1 -1
  38. package/superstruct/dist/types.d.ts +1 -1
  39. package/superstruct/package.json +2 -1
  40. package/superstruct/src/__tests__/__fixtures__/data.ts +73 -0
  41. package/superstruct/src/__tests__/__snapshots__/superstruct.ts.snap +26 -56
  42. package/superstruct/src/__tests__/superstruct.ts +6 -65
  43. package/superstruct/src/superstruct.ts +20 -53
  44. package/superstruct/src/types.ts +1 -1
  45. package/vest/dist/vest.js +1 -1
  46. package/vest/dist/vest.js.map +1 -1
  47. package/vest/dist/vest.mjs +1 -1
  48. package/vest/dist/vest.modern.js +1 -1
  49. package/vest/dist/vest.modern.js.map +1 -1
  50. package/vest/dist/vest.module.js +1 -1
  51. package/vest/dist/vest.module.js.map +1 -1
  52. package/vest/dist/vest.umd.js +1 -1
  53. package/vest/dist/vest.umd.js.map +1 -1
  54. package/vest/package.json +3 -1
  55. package/vest/src/__tests__/__fixtures__/data.ts +67 -0
  56. package/vest/src/__tests__/__snapshots__/vest.ts.snap +28 -0
  57. package/vest/src/__tests__/vest.ts +22 -95
  58. package/vest/src/types.ts +1 -1
  59. package/vest/src/vest.ts +31 -42
  60. package/yup/dist/types.d.ts +4 -3
  61. package/yup/dist/yup.js +1 -1
  62. package/yup/dist/yup.js.map +1 -1
  63. package/yup/dist/yup.mjs +1 -1
  64. package/yup/dist/yup.modern.js +1 -1
  65. package/yup/dist/yup.modern.js.map +1 -1
  66. package/yup/dist/yup.module.js +1 -1
  67. package/yup/dist/yup.module.js.map +1 -1
  68. package/yup/dist/yup.umd.js +1 -1
  69. package/yup/dist/yup.umd.js.map +1 -1
  70. package/yup/package.json +2 -1
  71. package/yup/src/__tests__/__fixtures__/data.ts +65 -0
  72. package/yup/src/__tests__/__snapshots__/yup.ts.snap +99 -13
  73. package/yup/src/__tests__/yup.ts +23 -97
  74. package/yup/src/types.ts +6 -3
  75. package/yup/src/yup.ts +30 -60
  76. package/zod/dist/types.d.ts +1 -1
  77. package/zod/dist/zod.js +1 -1
  78. package/zod/dist/zod.js.map +1 -1
  79. package/zod/dist/zod.mjs +1 -1
  80. package/zod/dist/zod.modern.js +1 -1
  81. package/zod/dist/zod.modern.js.map +1 -1
  82. package/zod/dist/zod.module.js +1 -1
  83. package/zod/dist/zod.module.js.map +1 -1
  84. package/zod/dist/zod.umd.js +1 -1
  85. package/zod/dist/zod.umd.js.map +1 -1
  86. package/zod/src/__tests__/__fixtures__/data.ts +68 -0
  87. package/zod/src/__tests__/__snapshots__/zod.ts.snap +146 -0
  88. package/zod/src/__tests__/zod.ts +19 -79
  89. package/zod/src/types.ts +1 -1
  90. package/zod/src/zod.ts +45 -50
  91. package/dist/convertArrayToPathName.d.ts +0 -1
@@ -1,77 +1,18 @@
1
- import {
2
- object,
3
- number,
4
- string,
5
- optional,
6
- pattern,
7
- size,
8
- union,
9
- min,
10
- max,
11
- Infer,
12
- define,
13
- array,
14
- boolean,
15
- } from 'superstruct';
16
1
  import { superstructResolver } from '..';
17
-
18
- const Password = define('Password', (value, ctx) =>
19
- value === ctx.branch[0].password);
20
-
21
- const schema = object({
22
- username: size(pattern(string(), /^\w+$/), 3, 30),
23
- password: pattern(string(), /^[a-zA-Z0-9]{3,30}/),
24
- repeatPassword: Password,
25
- accessToken: optional(union([string(), number()])),
26
- birthYear: optional(max(min(number(), 1900), 2013)),
27
- email: optional(pattern(string(), /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/)),
28
- tags: array(string()),
29
- enabled: boolean(),
30
- });
2
+ import { invalidData, schema, validData, fields } from './__fixtures__/data';
31
3
 
32
4
  describe('superstructResolver', () => {
33
5
  it('should return values from superstructResolver when validation pass', async () => {
34
- const data: Infer<typeof schema> = {
35
- username: 'Doe',
36
- password: 'Password123',
37
- repeatPassword: 'Password123',
38
- birthYear: 2000,
39
- email: 'john@doe.com',
40
- tags: ['tag1', 'tag2'],
41
- enabled: true,
42
- };
43
-
44
- const result = await superstructResolver(schema)(data, undefined, {
45
- fields: {},
6
+ const result = await superstructResolver(schema)(validData, undefined, {
7
+ fields,
46
8
  });
47
9
 
48
- expect(result).toEqual({ errors: {}, values: data });
10
+ expect(result).toEqual({ errors: {}, values: validData });
49
11
  });
50
12
 
51
13
  it('should return a single error from superstructResolver when validation fails', async () => {
52
- const data = {
53
- password: '___',
54
- email: '',
55
- birthYear: 'birthYear',
56
- };
57
-
58
- const result = await superstructResolver(schema)(data, undefined, {
59
- fields: {},
60
- });
61
-
62
- expect(result).toMatchSnapshot();
63
- });
64
-
65
- it('should return all the errors from superstructResolver when validation fails with `validateAllFieldCriteria` set to true', async () => {
66
- const data = {
67
- password: '___',
68
- email: '',
69
- birthYear: 'birthYear',
70
- };
71
-
72
- const result = await superstructResolver(schema)(data, undefined, {
73
- fields: {},
74
- criteriaMode: 'all',
14
+ const result = await superstructResolver(schema)(invalidData, undefined, {
15
+ fields,
75
16
  });
76
17
 
77
18
  expect(result).toMatchSnapshot();
@@ -1,63 +1,30 @@
1
- import { appendErrors, transformToNestObject } from 'react-hook-form';
1
+ import { FieldError } from 'react-hook-form';
2
+ import { toNestError } from '@hookform/resolvers';
3
+
2
4
  import { StructError, validate } from 'superstruct';
3
- // @ts-expect-error maybe fixed after the first publish ?
4
- import { convertArrayToPathName } from '@hookform/resolvers';
5
5
  import { Resolver } from './types';
6
6
 
7
- const parseErrorSchema = (
8
- error: StructError,
9
- validateAllFieldCriteria: boolean,
10
- ) =>
11
- error
12
- .failures()
13
- .reduce((previous: Record<string, any>, { path, message = '', type }) => {
14
- const currentPath = convertArrayToPathName(path);
15
- return {
16
- ...previous,
17
- ...(path
18
- ? previous[currentPath] && validateAllFieldCriteria
19
- ? {
20
- [currentPath]: appendErrors(
21
- currentPath,
22
- validateAllFieldCriteria,
23
- previous,
24
- type || '',
25
- message,
26
- ),
27
- }
28
- : {
29
- [currentPath]: previous[currentPath] || {
30
- message,
31
- type,
32
- ...(validateAllFieldCriteria
33
- ? {
34
- types: { [type || '']: message || true },
35
- }
36
- : {}),
37
- },
38
- }
39
- : {}),
40
- };
41
- }, {});
7
+ const parseErrorSchema = (error: StructError) =>
8
+ error.failures().reduce<Record<string, FieldError>>(
9
+ (previous, error) =>
10
+ (previous[error.path.join('.')] = {
11
+ message: error.message,
12
+ type: error.type,
13
+ }) && previous,
14
+ {},
15
+ );
42
16
 
43
- export const superstructResolver: Resolver = (schema, options) => async (
17
+ export const superstructResolver: Resolver = (schema, resolverOptions) => (
44
18
  values,
45
- _context,
46
- { criteriaMode },
19
+ _,
20
+ options,
47
21
  ) => {
48
- const [errors, result] = validate(values, schema, options);
49
-
50
- if (errors != null) {
51
- return {
52
- values: {},
53
- errors: transformToNestObject(
54
- parseErrorSchema(errors, criteriaMode === 'all'),
55
- ),
56
- };
57
- }
22
+ const result = validate(values, schema, resolverOptions);
58
23
 
59
24
  return {
60
- values: result,
61
- errors: {},
25
+ values: result[1] || {},
26
+ errors: result[0]
27
+ ? toNestError(parseErrorSchema(result[0]), options.fields)
28
+ : {},
62
29
  };
63
30
  };
@@ -15,4 +15,4 @@ export type Resolver = <T extends Struct<any, any>>(
15
15
  values: UnpackNestedValue<TFieldValues>,
16
16
  context: TContext | undefined,
17
17
  options: ResolverOptions<TFieldValues>,
18
- ) => Promise<ResolverResult<TFieldValues>>;
18
+ ) => ResolverResult<TFieldValues>;
package/vest/dist/vest.js CHANGED
@@ -1,2 +1,2 @@
1
- var r=require("react-hook-form");function e(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var t=e(require("vest/promisify"));function n(){return(n=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}).apply(this,arguments)}exports.vestResolver=function(e,o,a){var s=(void 0===a?{mode:"async"}:a).mode;return function(o,a,u){var i=u.criteriaMode;try{var c,f=function(){var e,t,a=c.getErrors();return c.hasErrors()?{values:{},errors:r.transformToNestObject((e=a,t="all"===i,Object.entries(e).reduce(function(r,e){var o,a=e[1];return n({},r,((o={})[e[0]]=n({type:"",message:a[0]},t?{types:a.reduce(function(r,e,t){var o;return n({},r,((o={})[t]=e,o))},{})}:{}),o))},{})))}:{values:o,errors:{}}},v=function(){if("async"===s){var r=t.default(e);return Promise.resolve(r(o)).then(function(r){c=r})}c=e(o)}();return Promise.resolve(v&&v.then?v.then(f):f())}catch(r){return Promise.reject(r)}}};
1
+ var r=require("@hookform/resolvers");function e(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var t=e(require("vest/promisify")),o=function(r,e){var t={};for(var o in r)t[o]||(t[o]={message:r[o][0],type:""}),e&&(t[o].types=r[o].reduce(function(r,e,t){return(r[t]=e)&&r},{}));return t};exports.vestResolver=function(e,s,n){return void 0===n&&(n={}),function(s,u,i){try{var a=function(e){return e.hasErrors()?{values:{},errors:r.toNestError(o(e.getErrors(),"all"===i.criteriaMode),i.fields)}:{values:s,errors:{}}};return Promise.resolve("sync"===n.mode?a(e(s)):Promise.resolve(t.default(e)(s)).then(a))}catch(r){return Promise.reject(r)}}};
2
2
  //# sourceMappingURL=vest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vest.js","sources":["../src/vest.ts"],"sourcesContent":["import { transformToNestObject } from 'react-hook-form';\nimport promisify from 'vest/promisify';\nimport { DraftResult, IVestResult } from 'vest/vestResult';\nimport type { VestErrors, Resolver } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n return Object.entries(vestError).reduce((prev, [key, value]) => {\n return {\n ...prev,\n [key]: {\n type: '',\n message: value[0],\n ...(validateAllFieldCriteria\n ? {\n types: value.reduce((prev, message, index) => {\n return {\n ...prev,\n [index]: message,\n };\n }, {}),\n }\n : {}),\n },\n };\n }, {});\n};\n\nexport const vestResolver: Resolver = (\n schema,\n _,\n { mode } = { mode: 'async' },\n) => async (values, _context, { criteriaMode }) => {\n let result: IVestResult | DraftResult;\n if (mode === 'async') {\n const validateSchema = promisify(schema);\n result = await validateSchema(values);\n } else {\n result = schema(values);\n }\n\n const errors = result.getErrors();\n\n if (!result.hasErrors()) {\n return { values, errors: {} };\n }\n\n return {\n values: {},\n errors: transformToNestObject(\n parseErrorSchema(errors, criteriaMode === 'all'),\n ),\n };\n};\n"],"names":["schema","_","mode","values","_context","criteriaMode","result","vestError","validateAllFieldCriteria","errors","getErrors","hasErrors","transformToNestObject","Object","entries","reduce","prev","value","type","message","types","index","validateSchema","promisify"],"mappings":"gXA8BsC,SACpCA,EACAC,SACEC,cAAS,CAAEA,KAAM,YAAjBA,qBACQC,EAAQC,SAAYC,IAAAA,qBAC1BC,eAQJ,IArCAC,EACAC,EAoCMC,EAASH,EAAOI,mBAEjBJ,EAAOK,YAIL,CACLR,OAAQ,GACRM,OAAQG,yBA7CVL,EA8CqBE,EA7CrBD,EA6C8C,QAAjBH,EA3CtBQ,OAAOC,QAAQP,GAAWQ,OAAO,SAACC,WAAYC,OACnD,YACKD,mBAEDE,KAAM,GACNC,QAASF,EAAM,IACXT,EACA,CACEY,MAAOH,EAAMF,OAAO,SAACC,EAAMG,EAASE,SAClC,YACKL,UACFK,GAAQF,OAEV,KAEL,SAGP,OAmBM,CAAEhB,OAAAA,EAAQM,OAAQ,qBAVd,UAATP,GACF,IAAMoB,EAAiBC,UAAUvB,0BAClBsB,EAAenB,qBAA9BG,MAEAA,EAASN,EAAOG,sDAVkB"}
1
+ {"version":3,"file":"vest.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestError } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport promisify from 'vest/promisify';\nimport type { VestErrors, Resolver } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n const errors: Record<string, FieldError> = {};\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce<Record<number, string>>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\nexport const vestResolver: Resolver = (\n schema,\n _,\n resolverOptions = {},\n) => async (values, _context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema(values)\n : await promisify(schema)(values);\n\n return result.hasErrors()\n ? {\n values: {},\n errors: toNestError(\n parseErrorSchema(result.getErrors(), options.criteriaMode === 'all'),\n options.fields,\n ),\n }\n : { values, errors: {} };\n};\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","path","message","type","types","reduce","acc","index","schema","_","resolverOptions","values","_context","options","result","hasErrors","toNestError","getErrors","criteriaMode","fields","mode","promisify"],"mappings":"gJAKMA,EAAmB,SACvBC,EACAC,GAEA,IAAMC,EAAqC,GAC3C,IAAK,IAAMC,KAAQH,EACZE,EAAOC,KACVD,EAAOC,GAAQ,CAAEC,QAASJ,EAAUG,GAAM,GAAIE,KAAM,KAGlDJ,IACFC,EAAOC,GAAMG,MAAQN,EAAUG,GAAMI,OACnC,SAACC,EAAKJ,EAASK,UAAWD,EAAIC,GAASL,IAAYI,GACnD,KAIN,OAAON,wBAG6B,SACpCQ,EACAC,EACAC,mBAAAA,IAAAA,EAAkB,aACRC,EAAQC,EAAUC,sBACtBC,GAKN,OAAOA,EAAOC,YACV,CACEJ,OAAQ,GACRX,OAAQgB,cACNnB,EAAiBiB,EAAOG,YAAsC,QAAzBJ,EAAQK,cAC7CL,EAAQM,SAGZ,CAAER,OAAAA,EAAQX,OAAQ,4BAZK,SAAzBU,EAAgBU,OACZZ,EAAOG,oBACDU,UAAUb,EAAVa,CAAkBV,aARM"}
@@ -1,2 +1,2 @@
1
- import{transformToNestObject as r}from"react-hook-form";import e from"vest/promisify";function t(){return(t=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}).apply(this,arguments)}var n=function(n,o,a){var i=(void 0===a?{mode:"async"}:a).mode;return function(o,a,s){var c=s.criteriaMode;try{var u,v=function(){var e,n,a=u.getErrors();return u.hasErrors()?{values:{},errors:r((e=a,n="all"===c,Object.entries(e).reduce(function(r,e){var o,a=e[1];return t({},r,((o={})[e[0]]=t({type:"",message:a[0]},n?{types:a.reduce(function(r,e,n){var o;return t({},r,((o={})[n]=e,o))},{})}:{}),o))},{})))}:{values:o,errors:{}}},f=function(){if("async"===i){var r=e(n);return Promise.resolve(r(o)).then(function(r){u=r})}u=n(o)}();return Promise.resolve(f&&f.then?f.then(v):v())}catch(r){return Promise.reject(r)}}};export{n as vestResolver};
1
+ import{toNestError as r}from"@hookform/resolvers";import e from"vest/promisify";var o=function(r,e){var o={};for(var t in r)o[t]||(o[t]={message:r[t][0],type:""}),e&&(o[t].types=r[t].reduce(function(r,e,o){return(r[o]=e)&&r},{}));return o},t=function(t,s,n){return void 0===n&&(n={}),function(s,i,u){try{var a=function(e){return e.hasErrors()?{values:{},errors:r(o(e.getErrors(),"all"===u.criteriaMode),u.fields)}:{values:s,errors:{}}};return Promise.resolve("sync"===n.mode?a(t(s)):Promise.resolve(e(t)(s)).then(a))}catch(r){return Promise.reject(r)}}};export{t as vestResolver};
2
2
  //# sourceMappingURL=vest.module.js.map
@@ -1,2 +1,2 @@
1
- import{transformToNestObject as r}from"react-hook-form";import e from"vest/promisify";function t(){return(t=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o])}return r}).apply(this,arguments)}const o=(o,s,{mode:a}={mode:"async"})=>async(s,n,{criteriaMode:c})=>{let i;if("async"===a){const r=e(o);i=await r(s)}else i=o(s);const p=i.getErrors();return i.hasErrors()?{values:{},errors:r((l=p,f="all"===c,Object.entries(l).reduce((r,[e,o])=>t({},r,{[e]:t({type:"",message:o[0]},f?{types:o.reduce((r,e,o)=>t({},r,{[o]:e}),{})}:{})}),{})))}:{values:s,errors:{}};var l,f};export{o as vestResolver};
1
+ import{toNestError as r}from"@hookform/resolvers";import e from"vest/promisify";const o=(r,e)=>{const o={};for(const s in r)o[s]||(o[s]={message:r[s][0],type:""}),e&&(o[s].types=r[s].reduce((r,e,o)=>(r[o]=e)&&r,{}));return o},s=(s,t,a={})=>async(t,i,n)=>{const c="sync"===a.mode?s(t):await e(s)(t);return c.hasErrors()?{values:{},errors:r(o(c.getErrors(),"all"===n.criteriaMode),n.fields)}:{values:t,errors:{}}};export{s as vestResolver};
2
2
  //# sourceMappingURL=vest.modern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vest.modern.js","sources":["../src/vest.ts"],"sourcesContent":["import { transformToNestObject } from 'react-hook-form';\nimport promisify from 'vest/promisify';\nimport { DraftResult, IVestResult } from 'vest/vestResult';\nimport type { VestErrors, Resolver } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n return Object.entries(vestError).reduce((prev, [key, value]) => {\n return {\n ...prev,\n [key]: {\n type: '',\n message: value[0],\n ...(validateAllFieldCriteria\n ? {\n types: value.reduce((prev, message, index) => {\n return {\n ...prev,\n [index]: message,\n };\n }, {}),\n }\n : {}),\n },\n };\n }, {});\n};\n\nexport const vestResolver: Resolver = (\n schema,\n _,\n { mode } = { mode: 'async' },\n) => async (values, _context, { criteriaMode }) => {\n let result: IVestResult | DraftResult;\n if (mode === 'async') {\n const validateSchema = promisify(schema);\n result = await validateSchema(values);\n } else {\n result = schema(values);\n }\n\n const errors = result.getErrors();\n\n if (!result.hasErrors()) {\n return { values, errors: {} };\n }\n\n return {\n values: {},\n errors: transformToNestObject(\n parseErrorSchema(errors, criteriaMode === 'all'),\n ),\n };\n};\n"],"names":["vestResolver","schema","_","mode","async","values","_context","criteriaMode","result","validateSchema","promisify","errors","getErrors","hasErrors","transformToNestObject","vestError","validateAllFieldCriteria","Object","entries","reduce","prev","key","value","[object Object]","type","message","types","index"],"mappings":"qSAKA,MAyBaA,EAAyB,CACpCC,EACAC,GACEC,KAAAA,GAAS,CAAEA,KAAM,WAChBC,MAAOC,EAAQC,GAAYC,aAAAA,MAC9B,IAAIC,EACJ,GAAa,UAATL,EAAkB,CACpB,MAAMM,EAAiBC,EAAUT,GACjCO,QAAeC,EAAeJ,QAE9BG,EAASP,EAAOI,GAGlB,MAAMM,EAASH,EAAOI,YAEtB,OAAKJ,EAAOK,YAIL,CACLR,OAAQ,GACRM,OAAQG,GA7CVC,EA8CqBJ,EA7CrBK,EA6C8C,QAAjBT,EA3CtBU,OAAOC,QAAQH,GAAWI,OAAO,CAACC,GAAOC,EAAKC,UAE9CF,GACHG,CAACF,MACCG,KAAM,GACNC,QAASH,EAAM,IACXN,EACA,CACEU,MAAOJ,EAAMH,OAAO,CAACC,EAAMK,EAASE,SAE7BP,GACHG,CAACI,GAAQF,IAEV,KAEL,MAGP,OAmBM,CAAEpB,OAAAA,EAAQM,OAAQ,IAzCJ,IACvBI,EACAC"}
1
+ {"version":3,"file":"vest.modern.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestError } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport promisify from 'vest/promisify';\nimport type { VestErrors, Resolver } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n const errors: Record<string, FieldError> = {};\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce<Record<number, string>>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\nexport const vestResolver: Resolver = (\n schema,\n _,\n resolverOptions = {},\n) => async (values, _context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema(values)\n : await promisify(schema)(values);\n\n return result.hasErrors()\n ? {\n values: {},\n errors: toNestError(\n parseErrorSchema(result.getErrors(), options.criteriaMode === 'all'),\n options.fields,\n ),\n }\n : { values, errors: {} };\n};\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","path","message","type","types","reduce","acc","index","vestResolver","schema","_","resolverOptions","async","values","_context","options","result","mode","promisify","hasErrors","toNestError","getErrors","criteriaMode","fields"],"mappings":"gFAKA,MAAMA,EAAmB,CACvBC,EACAC,KAEA,MAAMC,EAAqC,GAC3C,IAAK,MAAMC,KAAQH,EACZE,EAAOC,KACVD,EAAOC,GAAQ,CAAEC,QAASJ,EAAUG,GAAM,GAAIE,KAAM,KAGlDJ,IACFC,EAAOC,GAAMG,MAAQN,EAAUG,GAAMI,OACnC,CAACC,EAAKJ,EAASK,KAAWD,EAAIC,GAASL,IAAYI,EACnD,KAIN,OAAON,GAGIQ,EAAyB,CACpCC,EACAC,EACAC,EAAkB,KACfC,MAAOC,EAAQC,EAAUC,KAC5B,MAAMC,EACqB,SAAzBL,EAAgBM,KACZR,EAAOI,SACDK,EAAUT,EAAVS,CAAkBL,GAE9B,OAAOG,EAAOG,YACV,CACEN,OAAQ,GACRb,OAAQoB,EACNvB,EAAiBmB,EAAOK,YAAsC,QAAzBN,EAAQO,cAC7CP,EAAQQ,SAGZ,CAAEV,OAAAA,EAAQb,OAAQ"}
@@ -1,2 +1,2 @@
1
- import{transformToNestObject as r}from"react-hook-form";import e from"vest/promisify";function t(){return(t=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}).apply(this,arguments)}var n=function(n,o,a){var i=(void 0===a?{mode:"async"}:a).mode;return function(o,a,s){var c=s.criteriaMode;try{var u,v=function(){var e,n,a=u.getErrors();return u.hasErrors()?{values:{},errors:r((e=a,n="all"===c,Object.entries(e).reduce(function(r,e){var o,a=e[1];return t({},r,((o={})[e[0]]=t({type:"",message:a[0]},n?{types:a.reduce(function(r,e,n){var o;return t({},r,((o={})[n]=e,o))},{})}:{}),o))},{})))}:{values:o,errors:{}}},f=function(){if("async"===i){var r=e(n);return Promise.resolve(r(o)).then(function(r){u=r})}u=n(o)}();return Promise.resolve(f&&f.then?f.then(v):v())}catch(r){return Promise.reject(r)}}};export{n as vestResolver};
1
+ import{toNestError as r}from"@hookform/resolvers";import e from"vest/promisify";var o=function(r,e){var o={};for(var t in r)o[t]||(o[t]={message:r[t][0],type:""}),e&&(o[t].types=r[t].reduce(function(r,e,o){return(r[o]=e)&&r},{}));return o},t=function(t,s,n){return void 0===n&&(n={}),function(s,i,u){try{var a=function(e){return e.hasErrors()?{values:{},errors:r(o(e.getErrors(),"all"===u.criteriaMode),u.fields)}:{values:s,errors:{}}};return Promise.resolve("sync"===n.mode?a(t(s)):Promise.resolve(e(t)(s)).then(a))}catch(r){return Promise.reject(r)}}};export{t as vestResolver};
2
2
  //# sourceMappingURL=vest.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vest.module.js","sources":["../src/vest.ts"],"sourcesContent":["import { transformToNestObject } from 'react-hook-form';\nimport promisify from 'vest/promisify';\nimport { DraftResult, IVestResult } from 'vest/vestResult';\nimport type { VestErrors, Resolver } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n return Object.entries(vestError).reduce((prev, [key, value]) => {\n return {\n ...prev,\n [key]: {\n type: '',\n message: value[0],\n ...(validateAllFieldCriteria\n ? {\n types: value.reduce((prev, message, index) => {\n return {\n ...prev,\n [index]: message,\n };\n }, {}),\n }\n : {}),\n },\n };\n }, {});\n};\n\nexport const vestResolver: Resolver = (\n schema,\n _,\n { mode } = { mode: 'async' },\n) => async (values, _context, { criteriaMode }) => {\n let result: IVestResult | DraftResult;\n if (mode === 'async') {\n const validateSchema = promisify(schema);\n result = await validateSchema(values);\n } else {\n result = schema(values);\n }\n\n const errors = result.getErrors();\n\n if (!result.hasErrors()) {\n return { values, errors: {} };\n }\n\n return {\n values: {},\n errors: transformToNestObject(\n parseErrorSchema(errors, criteriaMode === 'all'),\n ),\n };\n};\n"],"names":["vestResolver","schema","_","mode","values","_context","criteriaMode","result","vestError","validateAllFieldCriteria","errors","getErrors","hasErrors","transformToNestObject","Object","entries","reduce","prev","value","type","message","types","index","validateSchema","promisify"],"mappings":"qSAKA,IAyBaA,EAAyB,SACpCC,EACAC,SACEC,cAAS,CAAEA,KAAM,YAAjBA,qBACQC,EAAQC,SAAYC,IAAAA,qBAC1BC,eAQJ,IArCAC,EACAC,EAoCMC,EAASH,EAAOI,mBAEjBJ,EAAOK,YAIL,CACLR,OAAQ,GACRM,OAAQG,GA7CVL,EA8CqBE,EA7CrBD,EA6C8C,QAAjBH,EA3CtBQ,OAAOC,QAAQP,GAAWQ,OAAO,SAACC,WAAYC,OACnD,YACKD,mBAEDE,KAAM,GACNC,QAASF,EAAM,IACXT,EACA,CACEY,MAAOH,EAAMF,OAAO,SAACC,EAAMG,EAASE,SAClC,YACKL,UACFK,GAAQF,OAEV,KAEL,SAGP,OAmBM,CAAEhB,OAAAA,EAAQM,OAAQ,qBAVd,UAATP,GACF,IAAMoB,EAAiBC,EAAUvB,0BAClBsB,EAAenB,qBAA9BG,MAEAA,EAASN,EAAOG,sDAVkB"}
1
+ {"version":3,"file":"vest.module.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestError } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport promisify from 'vest/promisify';\nimport type { VestErrors, Resolver } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n const errors: Record<string, FieldError> = {};\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce<Record<number, string>>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\nexport const vestResolver: Resolver = (\n schema,\n _,\n resolverOptions = {},\n) => async (values, _context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema(values)\n : await promisify(schema)(values);\n\n return result.hasErrors()\n ? {\n values: {},\n errors: toNestError(\n parseErrorSchema(result.getErrors(), options.criteriaMode === 'all'),\n options.fields,\n ),\n }\n : { values, errors: {} };\n};\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","path","message","type","types","reduce","acc","index","vestResolver","schema","_","resolverOptions","values","_context","options","result","hasErrors","toNestError","getErrors","criteriaMode","fields","mode","promisify"],"mappings":"gFAKA,IAAMA,EAAmB,SACvBC,EACAC,GAEA,IAAMC,EAAqC,GAC3C,IAAK,IAAMC,KAAQH,EACZE,EAAOC,KACVD,EAAOC,GAAQ,CAAEC,QAASJ,EAAUG,GAAM,GAAIE,KAAM,KAGlDJ,IACFC,EAAOC,GAAMG,MAAQN,EAAUG,GAAMI,OACnC,SAACC,EAAKJ,EAASK,UAAWD,EAAIC,GAASL,IAAYI,GACnD,KAIN,OAAON,GAGIQ,EAAyB,SACpCC,EACAC,EACAC,mBAAAA,IAAAA,EAAkB,aACRC,EAAQC,EAAUC,sBACtBC,GAKN,OAAOA,EAAOC,YACV,CACEJ,OAAQ,GACRZ,OAAQiB,EACNpB,EAAiBkB,EAAOG,YAAsC,QAAzBJ,EAAQK,cAC7CL,EAAQM,SAGZ,CAAER,OAAAA,EAAQZ,OAAQ,4BAZK,SAAzBW,EAAgBU,OACZZ,EAAOG,oBACDU,EAAUb,EAAVa,CAAkBV,aARM"}
@@ -1,2 +1,2 @@
1
- !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react-hook-form"),require("vest/promisify")):"function"==typeof define&&define.amd?define(["exports","react-hook-form","vest/promisify"],r):r((e||self).hookformResolversVest={},e.reactHookForm,e.promisify)}(this,function(e,r,t){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=o(t);function i(){return(i=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}e.vestResolver=function(e,t,o){var s=(void 0===o?{mode:"async"}:o).mode;return function(t,o,f){var u=f.criteriaMode;try{var a,c=function(){var e,o,n=a.getErrors();return a.hasErrors()?{values:{},errors:r.transformToNestObject((e=n,o="all"===u,Object.entries(e).reduce(function(e,r){var t,n=r[1];return i({},e,((t={})[r[0]]=i({type:"",message:n[0]},o?{types:n.reduce(function(e,r,t){var o;return i({},e,((o={})[t]=r,o))},{})}:{}),t))},{})))}:{values:t,errors:{}}},l=function(){if("async"===s){var r=n.default(e);return Promise.resolve(r(t)).then(function(e){a=e})}a=e(t)}();return Promise.resolve(l&&l.then?l.then(c):c())}catch(e){return Promise.reject(e)}}}});
1
+ !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("vest/promisify")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","vest/promisify"],r):r((e||self).hookformResolversVest={},e.hookformResolvers,e.promisify)}(this,function(e,r,o){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=t(o),n=function(e,r){var o={};for(var t in e)o[t]||(o[t]={message:e[t][0],type:""}),r&&(o[t].types=e[t].reduce(function(e,r,o){return(e[o]=r)&&e},{}));return o};e.vestResolver=function(e,o,t){return void 0===t&&(t={}),function(o,i,f){try{var u=function(e){return e.hasErrors()?{values:{},errors:r.toNestError(n(e.getErrors(),"all"===f.criteriaMode),f.fields)}:{values:o,errors:{}}};return Promise.resolve("sync"===t.mode?u(e(o)):Promise.resolve(s.default(e)(o)).then(u))}catch(e){return Promise.reject(e)}}}});
2
2
  //# sourceMappingURL=vest.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vest.umd.js","sources":["../src/vest.ts"],"sourcesContent":["import { transformToNestObject } from 'react-hook-form';\nimport promisify from 'vest/promisify';\nimport { DraftResult, IVestResult } from 'vest/vestResult';\nimport type { VestErrors, Resolver } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n return Object.entries(vestError).reduce((prev, [key, value]) => {\n return {\n ...prev,\n [key]: {\n type: '',\n message: value[0],\n ...(validateAllFieldCriteria\n ? {\n types: value.reduce((prev, message, index) => {\n return {\n ...prev,\n [index]: message,\n };\n }, {}),\n }\n : {}),\n },\n };\n }, {});\n};\n\nexport const vestResolver: Resolver = (\n schema,\n _,\n { mode } = { mode: 'async' },\n) => async (values, _context, { criteriaMode }) => {\n let result: IVestResult | DraftResult;\n if (mode === 'async') {\n const validateSchema = promisify(schema);\n result = await validateSchema(values);\n } else {\n result = schema(values);\n }\n\n const errors = result.getErrors();\n\n if (!result.hasErrors()) {\n return { values, errors: {} };\n }\n\n return {\n values: {},\n errors: transformToNestObject(\n parseErrorSchema(errors, criteriaMode === 'all'),\n ),\n };\n};\n"],"names":["schema","_","mode","values","_context","criteriaMode","result","vestError","validateAllFieldCriteria","errors","getErrors","hasErrors","transformToNestObject","Object","entries","reduce","prev","value","type","message","types","index","validateSchema","promisify"],"mappings":"wpBA8BsC,SACpCA,EACAC,SACEC,cAAS,CAAEA,KAAM,YAAjBA,qBACQC,EAAQC,SAAYC,IAAAA,qBAC1BC,eAQJ,IArCAC,EACAC,EAoCMC,EAASH,EAAOI,mBAEjBJ,EAAOK,YAIL,CACLR,OAAQ,GACRM,OAAQG,yBA7CVL,EA8CqBE,EA7CrBD,EA6C8C,QAAjBH,EA3CtBQ,OAAOC,QAAQP,GAAWQ,OAAO,SAACC,WAAYC,OACnD,YACKD,mBAEDE,KAAM,GACNC,QAASF,EAAM,IACXT,EACA,CACEY,MAAOH,EAAMF,OAAO,SAACC,EAAMG,EAASE,SAClC,YACKL,UACFK,GAAQF,OAEV,KAEL,SAGP,OAmBM,CAAEhB,OAAAA,EAAQM,OAAQ,qBAVd,UAATP,GACF,IAAMoB,EAAiBC,UAAUvB,0BAClBsB,EAAenB,qBAA9BG,MAEAA,EAASN,EAAOG,sDAVkB"}
1
+ {"version":3,"file":"vest.umd.js","sources":["../src/vest.ts"],"sourcesContent":["import { toNestError } from '@hookform/resolvers';\nimport { FieldError } from 'react-hook-form';\nimport promisify from 'vest/promisify';\nimport type { VestErrors, Resolver } from './types';\n\nconst parseErrorSchema = (\n vestError: VestErrors,\n validateAllFieldCriteria: boolean,\n) => {\n const errors: Record<string, FieldError> = {};\n for (const path in vestError) {\n if (!errors[path]) {\n errors[path] = { message: vestError[path][0], type: '' };\n }\n\n if (validateAllFieldCriteria) {\n errors[path].types = vestError[path].reduce<Record<number, string>>(\n (acc, message, index) => (acc[index] = message) && acc,\n {},\n );\n }\n }\n return errors;\n};\n\nexport const vestResolver: Resolver = (\n schema,\n _,\n resolverOptions = {},\n) => async (values, _context, options) => {\n const result =\n resolverOptions.mode === 'sync'\n ? schema(values)\n : await promisify(schema)(values);\n\n return result.hasErrors()\n ? {\n values: {},\n errors: toNestError(\n parseErrorSchema(result.getErrors(), options.criteriaMode === 'all'),\n options.fields,\n ),\n }\n : { values, errors: {} };\n};\n"],"names":["parseErrorSchema","vestError","validateAllFieldCriteria","errors","path","message","type","types","reduce","acc","index","schema","_","resolverOptions","values","_context","options","result","hasErrors","toNestError","getErrors","criteriaMode","fields","mode","promisify"],"mappings":"scAKMA,EAAmB,SACvBC,EACAC,GAEA,IAAMC,EAAqC,GAC3C,IAAK,IAAMC,KAAQH,EACZE,EAAOC,KACVD,EAAOC,GAAQ,CAAEC,QAASJ,EAAUG,GAAM,GAAIE,KAAM,KAGlDJ,IACFC,EAAOC,GAAMG,MAAQN,EAAUG,GAAMI,OACnC,SAACC,EAAKJ,EAASK,UAAWD,EAAIC,GAASL,IAAYI,GACnD,KAIN,OAAON,kBAG6B,SACpCQ,EACAC,EACAC,mBAAAA,IAAAA,EAAkB,aACRC,EAAQC,EAAUC,sBACtBC,GAKN,OAAOA,EAAOC,YACV,CACEJ,OAAQ,GACRX,OAAQgB,cACNnB,EAAiBiB,EAAOG,YAAsC,QAAzBJ,EAAQK,cAC7CL,EAAQM,SAGZ,CAAER,OAAAA,EAAQX,OAAQ,4BAZK,SAAzBU,EAAgBU,OACZZ,EAAOG,oBACDU,UAAUb,EAAVa,CAAkBV,aARM"}
package/vest/package.json CHANGED
@@ -11,6 +11,8 @@
11
11
  "types": "dist/index.d.ts",
12
12
  "license": "MIT",
13
13
  "peerDependencies": {
14
- "react-hook-form": ">=6.6.0"
14
+ "react-hook-form": ">=6.6.0",
15
+ "@hookform/resolvers": ">=2.0.0",
16
+ "vest": ">=3.0.0"
15
17
  }
16
18
  }
@@ -0,0 +1,67 @@
1
+ import { Field, InternalFieldName } from 'react-hook-form';
2
+ import * as vest from 'vest';
3
+
4
+ export const validationSuite = vest.create('form', (data: any = {}) => {
5
+ vest.test('username', 'Username is required', () => {
6
+ vest.enforce(data.username).isNotEmpty();
7
+ });
8
+
9
+ vest.test('username', 'Must be longer than 3 chars', () => {
10
+ vest.enforce(data.username).longerThan(3);
11
+ });
12
+
13
+ vest.test('deepObject.data', 'deepObject.data is required', () => {
14
+ vest.enforce(data.deepObject.data).isNotEmpty();
15
+ });
16
+
17
+ vest.test('password', 'Password is required', () => {
18
+ vest.enforce(data.password).isNotEmpty();
19
+ });
20
+
21
+ vest.test('password', 'Password must be at least 5 chars', () => {
22
+ vest.enforce(data.password).longerThanOrEquals(5);
23
+ });
24
+
25
+ vest.test('password', 'Password must contain a digit', () => {
26
+ vest.enforce(data.password).matches(/[0-9]/);
27
+ });
28
+
29
+ vest.test('password', 'Password must contain a symbol', () => {
30
+ vest.enforce(data.password).matches(/[^A-Za-z0-9]/);
31
+ });
32
+ });
33
+
34
+ export const validData = {
35
+ username: 'asdda',
36
+ password: 'asddfg123!',
37
+ deepObject: {
38
+ data: 'test',
39
+ },
40
+ };
41
+
42
+ export const invalidData = {
43
+ username: '',
44
+ password: 'a',
45
+ deepObject: {
46
+ data: '',
47
+ },
48
+ };
49
+
50
+ export const fields: Record<InternalFieldName, Field['_f']> = {
51
+ username: {
52
+ ref: { name: 'username' },
53
+ name: 'username',
54
+ },
55
+ password: {
56
+ ref: { name: 'password' },
57
+ name: 'password',
58
+ },
59
+ email: {
60
+ ref: { name: 'email' },
61
+ name: 'email',
62
+ },
63
+ birthday: {
64
+ ref: { name: 'birthday' },
65
+ name: 'birthday',
66
+ },
67
+ };
@@ -6,6 +6,7 @@ Object {
6
6
  "deepObject": Object {
7
7
  "data": Object {
8
8
  "message": "deepObject.data is required",
9
+ "ref": undefined,
9
10
  "type": "",
10
11
  "types": Object {
11
12
  "0": "deepObject.data is required",
@@ -14,6 +15,9 @@ Object {
14
15
  },
15
16
  "password": Object {
16
17
  "message": "Password must be at least 5 chars",
18
+ "ref": Object {
19
+ "name": "password",
20
+ },
17
21
  "type": "",
18
22
  "types": Object {
19
23
  "0": "Password must be at least 5 chars",
@@ -23,6 +27,9 @@ Object {
23
27
  },
24
28
  "username": Object {
25
29
  "message": "Username is required",
30
+ "ref": Object {
31
+ "name": "username",
32
+ },
26
33
  "type": "",
27
34
  "types": Object {
28
35
  "0": "Username is required",
@@ -40,6 +47,7 @@ Object {
40
47
  "deepObject": Object {
41
48
  "data": Object {
42
49
  "message": "deepObject.data is required",
50
+ "ref": undefined,
43
51
  "type": "",
44
52
  "types": Object {
45
53
  "0": "deepObject.data is required",
@@ -48,6 +56,9 @@ Object {
48
56
  },
49
57
  "password": Object {
50
58
  "message": "Password must be at least 5 chars",
59
+ "ref": Object {
60
+ "name": "password",
61
+ },
51
62
  "type": "",
52
63
  "types": Object {
53
64
  "0": "Password must be at least 5 chars",
@@ -57,6 +68,9 @@ Object {
57
68
  },
58
69
  "username": Object {
59
70
  "message": "Username is required",
71
+ "ref": Object {
72
+ "name": "username",
73
+ },
60
74
  "type": "",
61
75
  "types": Object {
62
76
  "0": "Username is required",
@@ -74,15 +88,22 @@ Object {
74
88
  "deepObject": Object {
75
89
  "data": Object {
76
90
  "message": "deepObject.data is required",
91
+ "ref": undefined,
77
92
  "type": "",
78
93
  },
79
94
  },
80
95
  "password": Object {
81
96
  "message": "Password must be at least 5 chars",
97
+ "ref": Object {
98
+ "name": "password",
99
+ },
82
100
  "type": "",
83
101
  },
84
102
  "username": Object {
85
103
  "message": "Username is required",
104
+ "ref": Object {
105
+ "name": "username",
106
+ },
86
107
  "type": "",
87
108
  },
88
109
  },
@@ -96,15 +117,22 @@ Object {
96
117
  "deepObject": Object {
97
118
  "data": Object {
98
119
  "message": "deepObject.data is required",
120
+ "ref": undefined,
99
121
  "type": "",
100
122
  },
101
123
  },
102
124
  "password": Object {
103
125
  "message": "Password must be at least 5 chars",
126
+ "ref": Object {
127
+ "name": "password",
128
+ },
104
129
  "type": "",
105
130
  },
106
131
  "username": Object {
107
132
  "message": "Username is required",
133
+ "ref": Object {
134
+ "name": "username",
135
+ },
108
136
  "type": "",
109
137
  },
110
138
  },