@hookform/resolvers 2.9.0 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import { Field, InternalFieldName } from 'react-hook-form';
4
4
  interface Data {
5
5
  username: string;
6
6
  password: string;
7
- deepObject: { data: string };
7
+ deepObject: { data: string; twoLayersDeep: { name: string } };
8
8
  }
9
9
 
10
10
  export const schema: JSONSchemaType<Data> = {
@@ -26,8 +26,14 @@ export const schema: JSONSchemaType<Data> = {
26
26
  nullable: true,
27
27
  properties: {
28
28
  data: { type: 'string' },
29
+ twoLayersDeep: {
30
+ type: 'object',
31
+ properties: { name: { type: 'string' } },
32
+ additionalProperties: false,
33
+ required: ['name'],
34
+ },
29
35
  },
30
- required: ['data'],
36
+ required: ['data', 'twoLayersDeep'],
31
37
  },
32
38
  },
33
39
  required: ['username', 'password', 'deepObject'],
@@ -38,6 +44,9 @@ export const validData: Data = {
38
44
  username: 'jsun969',
39
45
  password: 'validPassword',
40
46
  deepObject: {
47
+ twoLayersDeep: {
48
+ name: 'deeper',
49
+ },
41
50
  data: 'data',
42
51
  },
43
52
  };
@@ -47,6 +56,7 @@ export const invalidData = {
47
56
  password: 'invalid-password',
48
57
  deepObject: {
49
58
  data: 233,
59
+ twoLayersDeep: { name: 123 }
50
60
  },
51
61
  };
52
62
 
@@ -66,6 +66,16 @@ Object {
66
66
  "type": "must be string",
67
67
  },
68
68
  },
69
+ "twoLayersDeep": Object {
70
+ "name": Object {
71
+ "message": "must be string",
72
+ "ref": undefined,
73
+ "type": "type",
74
+ "types": Object {
75
+ "type": "must be string",
76
+ },
77
+ },
78
+ },
69
79
  },
70
80
  "password": Object {
71
81
  "message": "One uppercase character",
@@ -104,6 +114,16 @@ Object {
104
114
  "type": "must be string",
105
115
  },
106
116
  },
117
+ "twoLayersDeep": Object {
118
+ "name": Object {
119
+ "message": "must be string",
120
+ "ref": undefined,
121
+ "type": "type",
122
+ "types": Object {
123
+ "type": "must be string",
124
+ },
125
+ },
126
+ },
107
127
  },
108
128
  "password": Object {
109
129
  "message": "One uppercase character",
@@ -139,6 +159,13 @@ Object {
139
159
  "ref": undefined,
140
160
  "type": "type",
141
161
  },
162
+ "twoLayersDeep": Object {
163
+ "name": Object {
164
+ "message": "must be string",
165
+ "ref": undefined,
166
+ "type": "type",
167
+ },
168
+ },
142
169
  },
143
170
  "password": Object {
144
171
  "message": "One uppercase character",
@@ -168,6 +195,13 @@ Object {
168
195
  "ref": undefined,
169
196
  "type": "type",
170
197
  },
198
+ "twoLayersDeep": Object {
199
+ "name": Object {
200
+ "message": "must be string",
201
+ "ref": undefined,
202
+ "type": "type",
203
+ },
204
+ },
171
205
  },
172
206
  "password": Object {
173
207
  "message": "One uppercase character",
package/ajv/src/ajv.ts CHANGED
@@ -17,7 +17,7 @@ const parseErrorSchema = (
17
17
 
18
18
  return ajvErrors.reduce<Record<string, FieldError>>((previous, error) => {
19
19
  // `/deepObject/data` -> `deepObject.data`
20
- const path = error.instancePath.substring(1).replace('/', '.');
20
+ const path = error.instancePath.substring(1).replace(/\//g, '.');
21
21
 
22
22
  if (!previous[path]) {
23
23
  previous[path] = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hookform/resolvers",
3
3
  "amdName": "hookformResolvers",
4
- "version": "2.9.0",
4
+ "version": "2.9.1",
5
5
  "description": "React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts, Nope, computed-types and Typanion",
6
6
  "main": "dist/resolvers.js",
7
7
  "module": "dist/resolvers.module.js",