@hookform/resolvers 3.10.0 → 4.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.
- package/README.md +74 -5
- package/ajv/dist/ajv.js +1 -1
- package/ajv/dist/ajv.js.map +1 -1
- package/ajv/dist/ajv.mjs +1 -1
- package/ajv/dist/ajv.modern.mjs +1 -1
- package/ajv/dist/ajv.modern.mjs.map +1 -1
- package/ajv/dist/ajv.module.js +1 -1
- package/ajv/dist/ajv.module.js.map +1 -1
- package/ajv/dist/ajv.umd.js +1 -1
- package/ajv/dist/ajv.umd.js.map +1 -1
- package/ajv/dist/types.d.ts +8 -0
- package/ajv/src/__tests__/__fixtures__/data-errors.ts +216 -0
- package/ajv/src/__tests__/__snapshots__/ajv-errors.ts.snap +462 -0
- package/ajv/src/__tests__/__snapshots__/ajv.ts.snap +6 -6
- package/ajv/src/__tests__/ajv-errors.ts +227 -0
- package/ajv/src/ajv.ts +27 -14
- package/ajv/src/types.ts +8 -0
- package/arktype/dist/arktype.js +1 -1
- package/arktype/dist/arktype.js.map +1 -1
- package/arktype/dist/arktype.mjs +1 -1
- package/arktype/dist/arktype.modern.mjs +1 -1
- package/arktype/dist/arktype.modern.mjs.map +1 -1
- package/arktype/dist/arktype.module.js +1 -1
- package/arktype/dist/arktype.module.js.map +1 -1
- package/arktype/dist/arktype.umd.js +1 -1
- package/arktype/dist/arktype.umd.js.map +1 -1
- package/arktype/dist/types.d.ts +1 -1
- package/arktype/package.json +1 -1
- package/arktype/src/__tests__/Form-native-validation.tsx +3 -3
- package/arktype/src/__tests__/Form.tsx +2 -2
- package/arktype/src/__tests__/__fixtures__/data.ts +1 -1
- package/arktype/src/__tests__/__snapshots__/arktype.ts.snap +22 -415
- package/arktype/src/arktype.ts +17 -6
- package/arktype/src/types.ts +1 -1
- package/class-validator/dist/class-validator.js +1 -1
- package/class-validator/dist/class-validator.js.map +1 -1
- package/class-validator/dist/class-validator.mjs +1 -1
- package/class-validator/dist/class-validator.modern.mjs +1 -1
- package/class-validator/dist/class-validator.modern.mjs.map +1 -1
- package/class-validator/dist/class-validator.module.js +1 -1
- package/class-validator/dist/class-validator.module.js.map +1 -1
- package/class-validator/dist/class-validator.umd.js +1 -1
- package/class-validator/dist/class-validator.umd.js.map +1 -1
- package/class-validator/dist/types.d.ts +1 -1
- package/class-validator/src/__tests__/class-validator.ts +1 -1
- package/class-validator/src/class-validator.ts +1 -1
- package/class-validator/src/types.ts +1 -1
- package/dist/resolvers.js +1 -1
- package/dist/resolvers.js.map +1 -1
- package/dist/resolvers.mjs +1 -1
- package/dist/resolvers.mjs.map +1 -1
- package/dist/resolvers.module.js +1 -1
- package/dist/resolvers.module.js.map +1 -1
- package/dist/resolvers.umd.js +1 -1
- package/dist/resolvers.umd.js.map +1 -1
- package/effect-ts/dist/effect-ts.js +1 -1
- package/effect-ts/dist/effect-ts.js.map +1 -1
- package/effect-ts/dist/effect-ts.mjs +1 -1
- package/effect-ts/dist/effect-ts.modern.mjs +1 -1
- package/effect-ts/dist/effect-ts.modern.mjs.map +1 -1
- package/effect-ts/dist/effect-ts.module.js +1 -1
- package/effect-ts/dist/effect-ts.module.js.map +1 -1
- package/effect-ts/dist/effect-ts.umd.js +1 -1
- package/effect-ts/dist/effect-ts.umd.js.map +1 -1
- package/effect-ts/src/__tests__/__snapshots__/effect-ts.ts.snap +35 -1
- package/effect-ts/src/__tests__/effect-ts.ts +61 -0
- package/effect-ts/src/effect-ts.ts +31 -6
- package/io-ts/dist/io-ts.js +1 -1
- package/io-ts/dist/io-ts.js.map +1 -1
- package/io-ts/dist/io-ts.mjs +1 -1
- package/io-ts/dist/io-ts.modern.mjs +1 -1
- package/io-ts/dist/io-ts.modern.mjs.map +1 -1
- package/io-ts/dist/io-ts.module.js +1 -1
- package/io-ts/dist/io-ts.module.js.map +1 -1
- package/io-ts/dist/io-ts.umd.js +1 -1
- package/io-ts/dist/io-ts.umd.js.map +1 -1
- package/package.json +46 -34
- package/standard-schema/dist/index.d.ts +2 -0
- package/standard-schema/dist/standard-schema.d.ts +2 -0
- package/standard-schema/dist/standard-schema.js +2 -0
- package/standard-schema/dist/standard-schema.js.map +1 -0
- package/standard-schema/dist/standard-schema.mjs +2 -0
- package/standard-schema/dist/standard-schema.modern.mjs +2 -0
- package/standard-schema/dist/standard-schema.modern.mjs.map +1 -0
- package/standard-schema/dist/standard-schema.module.js +2 -0
- package/standard-schema/dist/standard-schema.module.js.map +1 -0
- package/standard-schema/dist/standard-schema.umd.js +2 -0
- package/standard-schema/dist/standard-schema.umd.js.map +1 -0
- package/standard-schema/dist/types.d.ts +3 -0
- package/standard-schema/package.json +18 -0
- package/standard-schema/src/__tests__/Form-native-validation.tsx +82 -0
- package/standard-schema/src/__tests__/Form.tsx +56 -0
- package/standard-schema/src/__tests__/__fixtures__/data.ts +65 -0
- package/standard-schema/src/__tests__/__snapshots__/standard-schema.ts.snap +63 -0
- package/standard-schema/src/__tests__/standard-schema.ts +28 -0
- package/standard-schema/src/index.ts +2 -0
- package/standard-schema/src/standard-schema.ts +45 -0
- package/standard-schema/src/types.ts +10 -0
- package/superstruct/dist/superstruct.js +1 -1
- package/superstruct/dist/superstruct.js.map +1 -1
- package/superstruct/dist/superstruct.mjs +1 -1
- package/superstruct/dist/superstruct.modern.mjs +1 -1
- package/superstruct/dist/superstruct.modern.mjs.map +1 -1
- package/superstruct/dist/superstruct.module.js +1 -1
- package/superstruct/dist/superstruct.module.js.map +1 -1
- package/superstruct/dist/superstruct.umd.js +1 -1
- package/superstruct/dist/superstruct.umd.js.map +1 -1
- package/superstruct/src/superstruct.ts +1 -1
- package/typebox/src/__tests__/__snapshots__/typebox-compiler.ts.snap +21 -21
- package/typebox/src/__tests__/__snapshots__/typebox.ts.snap +21 -21
- package/typeschema/dist/typeschema.js +1 -1
- package/typeschema/dist/typeschema.js.map +1 -1
- package/typeschema/dist/typeschema.mjs +1 -1
- package/typeschema/dist/typeschema.modern.mjs +1 -1
- package/typeschema/dist/typeschema.modern.mjs.map +1 -1
- package/typeschema/dist/typeschema.module.js +1 -1
- package/typeschema/dist/typeschema.module.js.map +1 -1
- package/typeschema/dist/typeschema.umd.js +1 -1
- package/typeschema/dist/typeschema.umd.js.map +1 -1
- package/typeschema/src/typeschema.ts +3 -1
- package/valibot/dist/valibot.js +1 -1
- package/valibot/dist/valibot.js.map +1 -1
- package/valibot/dist/valibot.mjs +1 -1
- package/valibot/dist/valibot.modern.mjs +1 -1
- package/valibot/dist/valibot.modern.mjs.map +1 -1
- package/valibot/dist/valibot.module.js +1 -1
- package/valibot/dist/valibot.module.js.map +1 -1
- package/valibot/dist/valibot.umd.js +1 -1
- package/valibot/dist/valibot.umd.js.map +1 -1
- package/valibot/package.json +1 -1
- package/valibot/src/__tests__/valibot.ts +1 -1
- package/valibot/src/valibot.ts +3 -1
- package/vine/dist/vine.js +1 -1
- package/vine/dist/vine.js.map +1 -1
- package/vine/dist/vine.mjs +1 -1
- package/vine/dist/vine.modern.mjs +1 -1
- package/vine/dist/vine.modern.mjs.map +1 -1
- package/vine/dist/vine.module.js +1 -1
- package/vine/dist/vine.module.js.map +1 -1
- package/vine/dist/vine.umd.js +1 -1
- package/vine/dist/vine.umd.js.map +1 -1
- package/vine/src/vine.ts +1 -1
- package/yup/dist/yup.js +1 -1
- package/yup/dist/yup.js.map +1 -1
- package/yup/dist/yup.mjs +1 -1
- package/yup/dist/yup.modern.mjs +1 -1
- package/yup/dist/yup.modern.mjs.map +1 -1
- package/yup/dist/yup.module.js +1 -1
- package/yup/dist/yup.module.js.map +1 -1
- package/yup/dist/yup.umd.js +1 -1
- package/yup/dist/yup.umd.js.map +1 -1
- package/yup/src/yup.ts +1 -1
- package/zod/dist/zod.js +1 -1
- package/zod/dist/zod.js.map +1 -1
- package/zod/dist/zod.mjs +1 -1
- package/zod/dist/zod.modern.mjs +1 -1
- package/zod/dist/zod.modern.mjs.map +1 -1
- package/zod/dist/zod.module.js +1 -1
- package/zod/dist/zod.module.js.map +1 -1
- package/zod/dist/zod.umd.js +1 -1
- package/zod/dist/zod.umd.js.map +1 -1
- package/zod/src/zod.ts +1 -1
|
@@ -3,463 +3,70 @@
|
|
|
3
3
|
exports[`arktypeResolver > should return a single error from arktypeResolver when validation fails 1`] = `
|
|
4
4
|
{
|
|
5
5
|
"errors": {
|
|
6
|
-
"accessToken":
|
|
7
|
-
"
|
|
8
|
-
"data": {
|
|
9
|
-
"birthYear": "birthYear",
|
|
10
|
-
"email": "",
|
|
11
|
-
"like": [
|
|
12
|
-
{
|
|
13
|
-
"id": "z",
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
"password": "___",
|
|
17
|
-
"url": "abc",
|
|
18
|
-
},
|
|
19
|
-
"input": {
|
|
20
|
-
"code": "required",
|
|
21
|
-
"missingValueDescription": "a number or a string",
|
|
22
|
-
"relativePath": [
|
|
23
|
-
"accessToken",
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
"missingValueDescription": "a number or a string",
|
|
27
|
-
"nodeConfig": {
|
|
28
|
-
"actual": [Function],
|
|
29
|
-
"description": [Function],
|
|
30
|
-
"expected": [Function],
|
|
31
|
-
"message": [Function],
|
|
32
|
-
"problem": [Function],
|
|
33
|
-
},
|
|
34
|
-
"path": [
|
|
35
|
-
"accessToken",
|
|
36
|
-
],
|
|
6
|
+
"accessToken": {
|
|
7
|
+
"message": "accessToken must be a number or a string (was missing)",
|
|
37
8
|
"ref": undefined,
|
|
38
|
-
"relativePath": [
|
|
39
|
-
"accessToken",
|
|
40
|
-
],
|
|
41
9
|
"type": "required",
|
|
42
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
43
10
|
},
|
|
44
|
-
"birthYear":
|
|
45
|
-
"
|
|
46
|
-
"data": "birthYear",
|
|
47
|
-
"description": "a number",
|
|
48
|
-
"domain": "number",
|
|
49
|
-
"input": {
|
|
50
|
-
"code": "domain",
|
|
51
|
-
"description": "a number",
|
|
52
|
-
"domain": "number",
|
|
53
|
-
},
|
|
54
|
-
"nodeConfig": {
|
|
55
|
-
"actual": [Function],
|
|
56
|
-
"description": [Function],
|
|
57
|
-
"expected": [Function],
|
|
58
|
-
"message": [Function],
|
|
59
|
-
"problem": [Function],
|
|
60
|
-
},
|
|
61
|
-
"path": [
|
|
62
|
-
"birthYear",
|
|
63
|
-
],
|
|
11
|
+
"birthYear": {
|
|
12
|
+
"message": "birthYear must be a number (was a string)",
|
|
64
13
|
"ref": undefined,
|
|
65
14
|
"type": "domain",
|
|
66
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
67
15
|
},
|
|
68
|
-
"dateStr":
|
|
69
|
-
"
|
|
70
|
-
"data": {
|
|
71
|
-
"birthYear": "birthYear",
|
|
72
|
-
"email": "",
|
|
73
|
-
"like": [
|
|
74
|
-
{
|
|
75
|
-
"id": "z",
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
"password": "___",
|
|
79
|
-
"url": "abc",
|
|
80
|
-
},
|
|
81
|
-
"input": {
|
|
82
|
-
"code": "required",
|
|
83
|
-
"missingValueDescription": "a Date",
|
|
84
|
-
"relativePath": [
|
|
85
|
-
"dateStr",
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
"missingValueDescription": "a Date",
|
|
89
|
-
"nodeConfig": {
|
|
90
|
-
"actual": [Function],
|
|
91
|
-
"description": [Function],
|
|
92
|
-
"expected": [Function],
|
|
93
|
-
"message": [Function],
|
|
94
|
-
"problem": [Function],
|
|
95
|
-
},
|
|
96
|
-
"path": [
|
|
97
|
-
"dateStr",
|
|
98
|
-
],
|
|
16
|
+
"dateStr": {
|
|
17
|
+
"message": "dateStr must be a Date (was missing)",
|
|
99
18
|
"ref": undefined,
|
|
100
|
-
"relativePath": [
|
|
101
|
-
"dateStr",
|
|
102
|
-
],
|
|
103
19
|
"type": "required",
|
|
104
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
105
20
|
},
|
|
106
|
-
"email":
|
|
107
|
-
"
|
|
108
|
-
"data": "",
|
|
109
|
-
"description": "a valid email",
|
|
110
|
-
"flags": "",
|
|
111
|
-
"input": {
|
|
112
|
-
"code": "pattern",
|
|
113
|
-
"description": "a valid email",
|
|
114
|
-
"flags": "",
|
|
115
|
-
"rule": "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$",
|
|
116
|
-
},
|
|
117
|
-
"nodeConfig": {
|
|
118
|
-
"actual": [Function],
|
|
119
|
-
"description": [Function],
|
|
120
|
-
"expected": [Function],
|
|
121
|
-
"message": [Function],
|
|
122
|
-
"problem": [Function],
|
|
123
|
-
},
|
|
124
|
-
"path": [
|
|
125
|
-
"email",
|
|
126
|
-
],
|
|
21
|
+
"email": {
|
|
22
|
+
"message": "email must be an email address (was "")",
|
|
127
23
|
"ref": {
|
|
128
24
|
"name": "email",
|
|
129
25
|
},
|
|
130
|
-
"rule": "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$",
|
|
131
26
|
"type": "pattern",
|
|
132
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
133
27
|
},
|
|
134
|
-
"enabled":
|
|
135
|
-
"
|
|
136
|
-
"data": {
|
|
137
|
-
"birthYear": "birthYear",
|
|
138
|
-
"email": "",
|
|
139
|
-
"like": [
|
|
140
|
-
{
|
|
141
|
-
"id": "z",
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
"password": "___",
|
|
145
|
-
"url": "abc",
|
|
146
|
-
},
|
|
147
|
-
"input": {
|
|
148
|
-
"code": "required",
|
|
149
|
-
"missingValueDescription": "boolean",
|
|
150
|
-
"relativePath": [
|
|
151
|
-
"enabled",
|
|
152
|
-
],
|
|
153
|
-
},
|
|
154
|
-
"missingValueDescription": "boolean",
|
|
155
|
-
"nodeConfig": {
|
|
156
|
-
"actual": [Function],
|
|
157
|
-
"description": [Function],
|
|
158
|
-
"expected": [Function],
|
|
159
|
-
"message": [Function],
|
|
160
|
-
"problem": [Function],
|
|
161
|
-
},
|
|
162
|
-
"path": [
|
|
163
|
-
"enabled",
|
|
164
|
-
],
|
|
28
|
+
"enabled": {
|
|
29
|
+
"message": "enabled must be boolean (was missing)",
|
|
165
30
|
"ref": undefined,
|
|
166
|
-
"relativePath": [
|
|
167
|
-
"enabled",
|
|
168
|
-
],
|
|
169
31
|
"type": "required",
|
|
170
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
171
32
|
},
|
|
172
33
|
"like": [
|
|
173
34
|
{
|
|
174
|
-
"id":
|
|
175
|
-
"
|
|
176
|
-
"data": "z",
|
|
177
|
-
"description": "a number",
|
|
178
|
-
"domain": "number",
|
|
179
|
-
"input": {
|
|
180
|
-
"code": "domain",
|
|
181
|
-
"description": "a number",
|
|
182
|
-
"domain": "number",
|
|
183
|
-
},
|
|
184
|
-
"nodeConfig": {
|
|
185
|
-
"actual": [Function],
|
|
186
|
-
"description": [Function],
|
|
187
|
-
"expected": [Function],
|
|
188
|
-
"message": [Function],
|
|
189
|
-
"problem": [Function],
|
|
190
|
-
},
|
|
191
|
-
"path": [
|
|
192
|
-
"like",
|
|
193
|
-
0,
|
|
194
|
-
"id",
|
|
195
|
-
],
|
|
35
|
+
"id": {
|
|
36
|
+
"message": "like[0].id must be a number (was a string)",
|
|
196
37
|
"ref": undefined,
|
|
197
38
|
"type": "domain",
|
|
198
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
199
39
|
},
|
|
200
|
-
"name":
|
|
201
|
-
"
|
|
202
|
-
"data": {
|
|
203
|
-
"id": "z",
|
|
204
|
-
},
|
|
205
|
-
"input": {
|
|
206
|
-
"code": "required",
|
|
207
|
-
"missingValueDescription": "a string",
|
|
208
|
-
"relativePath": [
|
|
209
|
-
"name",
|
|
210
|
-
],
|
|
211
|
-
},
|
|
212
|
-
"missingValueDescription": "a string",
|
|
213
|
-
"nodeConfig": {
|
|
214
|
-
"actual": [Function],
|
|
215
|
-
"description": [Function],
|
|
216
|
-
"expected": [Function],
|
|
217
|
-
"message": [Function],
|
|
218
|
-
"problem": [Function],
|
|
219
|
-
},
|
|
220
|
-
"path": [
|
|
221
|
-
"like",
|
|
222
|
-
0,
|
|
223
|
-
"name",
|
|
224
|
-
],
|
|
40
|
+
"name": {
|
|
41
|
+
"message": "like[0].name must be a string (was missing)",
|
|
225
42
|
"ref": undefined,
|
|
226
|
-
"relativePath": [
|
|
227
|
-
"name",
|
|
228
|
-
],
|
|
229
43
|
"type": "required",
|
|
230
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
231
44
|
},
|
|
232
45
|
},
|
|
233
46
|
],
|
|
234
|
-
"password":
|
|
235
|
-
"
|
|
236
|
-
"data": "___",
|
|
237
|
-
"errors": [
|
|
238
|
-
ArkError {
|
|
239
|
-
"code": "pattern",
|
|
240
|
-
"data": "___",
|
|
241
|
-
"description": "matched by .*[A-Za-z].*",
|
|
242
|
-
"input": {
|
|
243
|
-
"code": "pattern",
|
|
244
|
-
"description": "matched by .*[A-Za-z].*",
|
|
245
|
-
"rule": ".*[A-Za-z].*",
|
|
246
|
-
},
|
|
247
|
-
"nodeConfig": {
|
|
248
|
-
"actual": [Function],
|
|
249
|
-
"description": [Function],
|
|
250
|
-
"expected": [Function],
|
|
251
|
-
"message": [Function],
|
|
252
|
-
"problem": [Function],
|
|
253
|
-
},
|
|
254
|
-
"path": [
|
|
255
|
-
"password",
|
|
256
|
-
],
|
|
257
|
-
"rule": ".*[A-Za-z].*",
|
|
258
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
259
|
-
},
|
|
260
|
-
ArkError {
|
|
261
|
-
"code": "pattern",
|
|
262
|
-
"data": "___",
|
|
263
|
-
"description": "matched by .*\\d.*",
|
|
264
|
-
"input": {
|
|
265
|
-
"code": "pattern",
|
|
266
|
-
"description": "matched by .*\\d.*",
|
|
267
|
-
"rule": ".*\\d.*",
|
|
268
|
-
},
|
|
269
|
-
"nodeConfig": {
|
|
270
|
-
"actual": [Function],
|
|
271
|
-
"description": [Function],
|
|
272
|
-
"expected": [Function],
|
|
273
|
-
"message": [Function],
|
|
274
|
-
"problem": [Function],
|
|
275
|
-
},
|
|
276
|
-
"path": [
|
|
277
|
-
"password",
|
|
278
|
-
],
|
|
279
|
-
"rule": ".*\\d.*",
|
|
280
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
281
|
-
},
|
|
282
|
-
],
|
|
283
|
-
"input": {
|
|
284
|
-
"code": "union",
|
|
285
|
-
"errors": [
|
|
286
|
-
ArkError {
|
|
287
|
-
"code": "pattern",
|
|
288
|
-
"data": "___",
|
|
289
|
-
"description": "matched by .*[A-Za-z].*",
|
|
290
|
-
"input": {
|
|
291
|
-
"code": "pattern",
|
|
292
|
-
"description": "matched by .*[A-Za-z].*",
|
|
293
|
-
"rule": ".*[A-Za-z].*",
|
|
294
|
-
},
|
|
295
|
-
"nodeConfig": {
|
|
296
|
-
"actual": [Function],
|
|
297
|
-
"description": [Function],
|
|
298
|
-
"expected": [Function],
|
|
299
|
-
"message": [Function],
|
|
300
|
-
"problem": [Function],
|
|
301
|
-
},
|
|
302
|
-
"path": [
|
|
303
|
-
"password",
|
|
304
|
-
],
|
|
305
|
-
"rule": ".*[A-Za-z].*",
|
|
306
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
307
|
-
},
|
|
308
|
-
ArkError {
|
|
309
|
-
"code": "pattern",
|
|
310
|
-
"data": "___",
|
|
311
|
-
"description": "matched by .*\\d.*",
|
|
312
|
-
"input": {
|
|
313
|
-
"code": "pattern",
|
|
314
|
-
"description": "matched by .*\\d.*",
|
|
315
|
-
"rule": ".*\\d.*",
|
|
316
|
-
},
|
|
317
|
-
"nodeConfig": {
|
|
318
|
-
"actual": [Function],
|
|
319
|
-
"description": [Function],
|
|
320
|
-
"expected": [Function],
|
|
321
|
-
"message": [Function],
|
|
322
|
-
"problem": [Function],
|
|
323
|
-
},
|
|
324
|
-
"path": [
|
|
325
|
-
"password",
|
|
326
|
-
],
|
|
327
|
-
"rule": ".*\\d.*",
|
|
328
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
329
|
-
},
|
|
330
|
-
],
|
|
331
|
-
},
|
|
332
|
-
"nodeConfig": {
|
|
333
|
-
"actual": [Function],
|
|
334
|
-
"description": [Function],
|
|
335
|
-
"expected": [Function],
|
|
336
|
-
"message": [Function],
|
|
337
|
-
"problem": [Function],
|
|
338
|
-
},
|
|
339
|
-
"path": [
|
|
340
|
-
"password",
|
|
341
|
-
],
|
|
47
|
+
"password": {
|
|
48
|
+
"message": "password must be matched by .*[A-Za-z].* or matched by .*\\d.* (was "___")",
|
|
342
49
|
"ref": {
|
|
343
50
|
"name": "password",
|
|
344
51
|
},
|
|
345
52
|
"type": "union",
|
|
346
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
347
53
|
},
|
|
348
|
-
"repeatPassword":
|
|
349
|
-
"
|
|
350
|
-
"data": {
|
|
351
|
-
"birthYear": "birthYear",
|
|
352
|
-
"email": "",
|
|
353
|
-
"like": [
|
|
354
|
-
{
|
|
355
|
-
"id": "z",
|
|
356
|
-
},
|
|
357
|
-
],
|
|
358
|
-
"password": "___",
|
|
359
|
-
"url": "abc",
|
|
360
|
-
},
|
|
361
|
-
"input": {
|
|
362
|
-
"code": "required",
|
|
363
|
-
"missingValueDescription": "a string",
|
|
364
|
-
"relativePath": [
|
|
365
|
-
"repeatPassword",
|
|
366
|
-
],
|
|
367
|
-
},
|
|
368
|
-
"missingValueDescription": "a string",
|
|
369
|
-
"nodeConfig": {
|
|
370
|
-
"actual": [Function],
|
|
371
|
-
"description": [Function],
|
|
372
|
-
"expected": [Function],
|
|
373
|
-
"message": [Function],
|
|
374
|
-
"problem": [Function],
|
|
375
|
-
},
|
|
376
|
-
"path": [
|
|
377
|
-
"repeatPassword",
|
|
378
|
-
],
|
|
54
|
+
"repeatPassword": {
|
|
55
|
+
"message": "repeatPassword must be a string (was missing)",
|
|
379
56
|
"ref": undefined,
|
|
380
|
-
"relativePath": [
|
|
381
|
-
"repeatPassword",
|
|
382
|
-
],
|
|
383
57
|
"type": "required",
|
|
384
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
385
58
|
},
|
|
386
|
-
"tags":
|
|
387
|
-
"
|
|
388
|
-
"data": {
|
|
389
|
-
"birthYear": "birthYear",
|
|
390
|
-
"email": "",
|
|
391
|
-
"like": [
|
|
392
|
-
{
|
|
393
|
-
"id": "z",
|
|
394
|
-
},
|
|
395
|
-
],
|
|
396
|
-
"password": "___",
|
|
397
|
-
"url": "abc",
|
|
398
|
-
},
|
|
399
|
-
"input": {
|
|
400
|
-
"code": "required",
|
|
401
|
-
"missingValueDescription": "an array",
|
|
402
|
-
"relativePath": [
|
|
403
|
-
"tags",
|
|
404
|
-
],
|
|
405
|
-
},
|
|
406
|
-
"missingValueDescription": "an array",
|
|
407
|
-
"nodeConfig": {
|
|
408
|
-
"actual": [Function],
|
|
409
|
-
"description": [Function],
|
|
410
|
-
"expected": [Function],
|
|
411
|
-
"message": [Function],
|
|
412
|
-
"problem": [Function],
|
|
413
|
-
},
|
|
414
|
-
"path": [
|
|
415
|
-
"tags",
|
|
416
|
-
],
|
|
59
|
+
"tags": {
|
|
60
|
+
"message": "tags must be an array (was missing)",
|
|
417
61
|
"ref": undefined,
|
|
418
|
-
"relativePath": [
|
|
419
|
-
"tags",
|
|
420
|
-
],
|
|
421
62
|
"type": "required",
|
|
422
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
423
63
|
},
|
|
424
|
-
"username":
|
|
425
|
-
"
|
|
426
|
-
"data": {
|
|
427
|
-
"birthYear": "birthYear",
|
|
428
|
-
"email": "",
|
|
429
|
-
"like": [
|
|
430
|
-
{
|
|
431
|
-
"id": "z",
|
|
432
|
-
},
|
|
433
|
-
],
|
|
434
|
-
"password": "___",
|
|
435
|
-
"url": "abc",
|
|
436
|
-
},
|
|
437
|
-
"input": {
|
|
438
|
-
"code": "required",
|
|
439
|
-
"missingValueDescription": "a string",
|
|
440
|
-
"relativePath": [
|
|
441
|
-
"username",
|
|
442
|
-
],
|
|
443
|
-
},
|
|
444
|
-
"missingValueDescription": "a string",
|
|
445
|
-
"nodeConfig": {
|
|
446
|
-
"actual": [Function],
|
|
447
|
-
"description": [Function],
|
|
448
|
-
"expected": [Function],
|
|
449
|
-
"message": [Function],
|
|
450
|
-
"problem": [Function],
|
|
451
|
-
},
|
|
452
|
-
"path": [
|
|
453
|
-
"username",
|
|
454
|
-
],
|
|
64
|
+
"username": {
|
|
65
|
+
"message": "username must be a string (was missing)",
|
|
455
66
|
"ref": {
|
|
456
67
|
"name": "username",
|
|
457
68
|
},
|
|
458
|
-
"relativePath": [
|
|
459
|
-
"username",
|
|
460
|
-
],
|
|
461
69
|
"type": "required",
|
|
462
|
-
Symbol(ArkTypeInternalKind): "error",
|
|
463
70
|
},
|
|
464
71
|
},
|
|
465
72
|
"values": {},
|
package/arktype/src/arktype.ts
CHANGED
|
@@ -3,11 +3,22 @@ import { ArkErrors } from 'arktype';
|
|
|
3
3
|
import { FieldError, FieldErrors } from 'react-hook-form';
|
|
4
4
|
import type { Resolver } from './types';
|
|
5
5
|
|
|
6
|
-
const parseErrorSchema = (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const parseErrorSchema = (arkErrors: ArkErrors): Record<string, FieldError> => {
|
|
7
|
+
const errors = [...arkErrors];
|
|
8
|
+
const fieldsErrors: Record<string, FieldError> = {};
|
|
9
|
+
|
|
10
|
+
for (; errors.length; ) {
|
|
11
|
+
const error = errors[0];
|
|
12
|
+
const _path = error.path.join('.');
|
|
13
|
+
|
|
14
|
+
if (!fieldsErrors[_path]) {
|
|
15
|
+
fieldsErrors[_path] = { message: error.message, type: error.code };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
errors.shift();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return fieldsErrors;
|
|
11
22
|
};
|
|
12
23
|
|
|
13
24
|
export const arktypeResolver: Resolver =
|
|
@@ -26,6 +37,6 @@ export const arktypeResolver: Resolver =
|
|
|
26
37
|
|
|
27
38
|
return {
|
|
28
39
|
errors: {} as FieldErrors,
|
|
29
|
-
values: resolverOptions.raw ? values : out,
|
|
40
|
+
values: resolverOptions.raw ? Object.assign({}, values) : out,
|
|
30
41
|
};
|
|
31
42
|
};
|
package/arktype/src/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type } from 'arktype';
|
|
2
2
|
import { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
|
|
3
3
|
|
|
4
|
-
export type Resolver = <T extends Type<any>>(
|
|
4
|
+
export type Resolver = <T extends Type<any, any>>(
|
|
5
5
|
schema: T,
|
|
6
6
|
schemaOptions?: undefined,
|
|
7
7
|
factoryOptions?: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var r=require("@hookform/resolvers"),e=require("class-transformer"),t=require("class-validator"),
|
|
1
|
+
var r=require("@hookform/resolvers"),e=require("class-transformer"),t=require("class-validator"),s=function r(e,t,s,a){return void 0===s&&(s={}),void 0===a&&(a=""),e.reduce(function(e,s){var i=a?a+"."+s.property:s.property;if(s.constraints){var o=Object.keys(s.constraints)[0];e[i]={type:o,message:s.constraints[o]};var n=e[i];t&&n&&Object.assign(n,{types:s.constraints})}return s.children&&s.children.length&&r(s.children,t,e,i),e},s)};exports.classValidatorResolver=function(a,i,o){return void 0===i&&(i={}),void 0===o&&(o={}),function(n,l,c){try{var v=i.validator,d=e.plainToClass(a,n,i.transformer);return Promise.resolve(("sync"===o.mode?t.validateSync:t.validate)(d,v)).then(function(e){return e.length?{values:{},errors:r.toNestErrors(s(e,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)}:(c.shouldUseNativeValidation&&r.validateFieldsNatively({},c),{values:o.raw?Object.assign({},n):d,errors:{}})})}catch(r){return Promise.reject(r)}}};
|
|
2
2
|
//# sourceMappingURL=class-validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-validator.js","sources":["../src/class-validator.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { plainToClass } from 'class-transformer';\nimport { ValidationError, validate, validateSync } from 'class-validator';\nimport { FieldErrors } from 'react-hook-form';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ValidationError[],\n validateAllFieldCriteria: boolean,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return errors.reduce((acc, error) => {\n const _path = path ? `${path}.${error.property}` : error.property;\n\n if (error.constraints) {\n const key = Object.keys(error.constraints)[0];\n acc[_path] = {\n type: key,\n message: error.constraints[key],\n };\n\n const _e = acc[_path];\n if (validateAllFieldCriteria && _e) {\n Object.assign(_e, { types: error.constraints });\n }\n }\n\n if (error.children && error.children.length) {\n parseErrors(error.children, validateAllFieldCriteria, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const classValidatorResolver: Resolver =\n (schema, schemaOptions = {}, resolverOptions = {}) =>\n async (values, _, options) => {\n const { transformer, validator } = schemaOptions;\n const data = plainToClass(schema, values, transformer);\n\n const rawErrors = await (resolverOptions.mode === 'sync'\n ? validateSync\n : validate)(data, validator);\n\n if (rawErrors.length) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrors(\n rawErrors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.
|
|
1
|
+
{"version":3,"file":"class-validator.js","sources":["../src/class-validator.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { plainToClass } from 'class-transformer';\nimport { ValidationError, validate, validateSync } from 'class-validator';\nimport { FieldErrors } from 'react-hook-form';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ValidationError[],\n validateAllFieldCriteria: boolean,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return errors.reduce((acc, error) => {\n const _path = path ? `${path}.${error.property}` : error.property;\n\n if (error.constraints) {\n const key = Object.keys(error.constraints)[0];\n acc[_path] = {\n type: key,\n message: error.constraints[key],\n };\n\n const _e = acc[_path];\n if (validateAllFieldCriteria && _e) {\n Object.assign(_e, { types: error.constraints });\n }\n }\n\n if (error.children && error.children.length) {\n parseErrors(error.children, validateAllFieldCriteria, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const classValidatorResolver: Resolver =\n (schema, schemaOptions = {}, resolverOptions = {}) =>\n async (values, _, options) => {\n const { transformer, validator } = schemaOptions;\n const data = plainToClass(schema, values, transformer);\n\n const rawErrors = await (resolverOptions.mode === 'sync'\n ? validateSync\n : validate)(data, validator);\n\n if (rawErrors.length) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrors(\n rawErrors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n errors: {},\n };\n };\n"],"names":["parseErrors","errors","validateAllFieldCriteria","parsedErrors","path","reduce","acc","error","_path","property","constraints","key","Object","keys","type","message","_e","assign","types","children","length","schema","schemaOptions","resolverOptions","values","_","options","validator","data","plainToClass","transformer","Promise","resolve","mode","validateSync","validate","then","rawErrors","toNestErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","raw","e","reject"],"mappings":"iGAMMA,EAAc,SAAdA,EACJC,EACAC,EACAC,EACAC,GAEA,YAH4B,IAA5BD,IAAAA,EAA4B,CAAE,QAC9BC,IAAAA,IAAAA,EAAO,IAEAH,EAAOI,OAAO,SAACC,EAAKC,GACzB,IAAMC,EAAQJ,EAAUA,MAAQG,EAAME,SAAaF,EAAME,SAEzD,GAAIF,EAAMG,YAAa,CACrB,IAAMC,EAAMC,OAAOC,KAAKN,EAAMG,aAAa,GAC3CJ,EAAIE,GAAS,CACXM,KAAMH,EACNI,QAASR,EAAMG,YAAYC,IAG7B,IAAMK,EAAKV,EAAIE,GACXN,GAA4Bc,GAC9BJ,OAAOK,OAAOD,EAAI,CAAEE,MAAOX,EAAMG,aAErC,CAMA,OAJIH,EAAMY,UAAYZ,EAAMY,SAASC,QACnCpB,EAAYO,EAAMY,SAAUjB,EAA0BI,EAAKE,GAGtDF,CACT,EAAGH,EACL,iCAGE,SAACkB,EAAQC,EAAoBC,eAAP,IAAbD,IAAAA,EAAgB,CAAA,QAAIC,IAAAA,IAAAA,EAAkB,CAAA,YACxCC,EAAQC,EAAGC,OAChB,IAAqBC,EAAcL,EAAdK,UACfC,EAAOC,EAAYA,aAACR,EAAQG,EADCF,EAA3BQ,aAC+C,OAAAC,QAAAC,SAEL,SAAzBT,EAAgBU,KACrCC,EAAAA,aACAC,EAAQA,UAAEP,EAAMD,IAAUS,KAFxBC,SAAAA,GAIN,OAAIA,EAAUjB,OACL,CACLI,OAAQ,GACRvB,OAAQqC,EAAYA,aAClBtC,EACEqC,GACCX,EAAQa,2BACkB,QAAzBb,EAAQc,cAEZd,KAKNA,EAAQa,2BAA6BE,EAAsBA,uBAAC,CAAE,EAAEf,GAEzD,CACLF,OAAQD,EAAgBmB,IAAM9B,OAAOK,OAAO,CAAE,EAAEO,GAAUI,EAC1D3B,OAAQ,CAAA,GACR,EACJ,CAAC,MAAA0C,GAAA,OAAAZ,QAAAa,OAAAD,EAAA,CAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{plainToClass as t}from"class-transformer";import{validateSync as o,validate as n}from"class-validator";var s=function r(e,t,o,n){return void 0===o&&(o={}),void 0===n&&(n=""),e.reduce(function(e,o){var s=n?n+"."+o.property:o.property;if(o.constraints){var i=Object.keys(o.constraints)[0];e[s]={type:i,message:o.constraints[i]};var a=e[s];t&&a&&Object.assign(a,{types:o.constraints})}return o.children&&o.children.length&&r(o.children,t,e,s),e},o)},i=function(i,a,c){return void 0===a&&(a={}),void 0===c&&(c={}),function(l,
|
|
1
|
+
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{plainToClass as t}from"class-transformer";import{validateSync as o,validate as n}from"class-validator";var s=function r(e,t,o,n){return void 0===o&&(o={}),void 0===n&&(n=""),e.reduce(function(e,o){var s=n?n+"."+o.property:o.property;if(o.constraints){var i=Object.keys(o.constraints)[0];e[s]={type:i,message:o.constraints[i]};var a=e[s];t&&a&&Object.assign(a,{types:o.constraints})}return o.children&&o.children.length&&r(o.children,t,e,s),e},o)},i=function(i,a,c){return void 0===a&&(a={}),void 0===c&&(c={}),function(l,v,d){try{var u=a.validator,m=t(i,l,a.transformer);return Promise.resolve(("sync"===c.mode?o:n)(m,u)).then(function(t){return t.length?{values:{},errors:r(s(t,!d.shouldUseNativeValidation&&"all"===d.criteriaMode),d)}:(d.shouldUseNativeValidation&&e({},d),{values:c.raw?Object.assign({},l):m,errors:{}})})}catch(r){return Promise.reject(r)}}};export{i as classValidatorResolver};
|
|
2
2
|
//# sourceMappingURL=class-validator.module.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toNestErrors as r,validateFieldsNatively as s}from"@hookform/resolvers";import{plainToClass as t}from"class-transformer";import{validateSync as e,validate as o}from"class-validator";const a=(r,s,t={},e="")=>r.reduce((r,t)=>{const o=e?`${e}.${t.property}`:t.property;if(t.constraints){const e=Object.keys(t.constraints)[0];r[o]={type:e,message:t.constraints[e]};const a=r[o];s&&a&&Object.assign(a,{types:t.constraints})}return t.children&&t.children.length&&a(t.children,s,r,o),r},t),n=(n,i={},c={})=>async(l,d,m)=>{const{transformer:p,validator:h}=i,
|
|
1
|
+
import{toNestErrors as r,validateFieldsNatively as s}from"@hookform/resolvers";import{plainToClass as t}from"class-transformer";import{validateSync as e,validate as o}from"class-validator";const a=(r,s,t={},e="")=>r.reduce((r,t)=>{const o=e?`${e}.${t.property}`:t.property;if(t.constraints){const e=Object.keys(t.constraints)[0];r[o]={type:e,message:t.constraints[e]};const a=r[o];s&&a&&Object.assign(a,{types:t.constraints})}return t.children&&t.children.length&&a(t.children,s,r,o),r},t),n=(n,i={},c={})=>async(l,d,m)=>{const{transformer:p,validator:h}=i,f=t(n,l,p),u=await("sync"===c.mode?e:o)(f,h);return u.length?{values:{},errors:r(a(u,!m.shouldUseNativeValidation&&"all"===m.criteriaMode),m)}:(m.shouldUseNativeValidation&&s({},m),{values:c.raw?Object.assign({},l):f,errors:{}})};export{n as classValidatorResolver};
|
|
2
2
|
//# sourceMappingURL=class-validator.modern.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-validator.modern.mjs","sources":["../src/class-validator.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { plainToClass } from 'class-transformer';\nimport { ValidationError, validate, validateSync } from 'class-validator';\nimport { FieldErrors } from 'react-hook-form';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ValidationError[],\n validateAllFieldCriteria: boolean,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return errors.reduce((acc, error) => {\n const _path = path ? `${path}.${error.property}` : error.property;\n\n if (error.constraints) {\n const key = Object.keys(error.constraints)[0];\n acc[_path] = {\n type: key,\n message: error.constraints[key],\n };\n\n const _e = acc[_path];\n if (validateAllFieldCriteria && _e) {\n Object.assign(_e, { types: error.constraints });\n }\n }\n\n if (error.children && error.children.length) {\n parseErrors(error.children, validateAllFieldCriteria, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const classValidatorResolver: Resolver =\n (schema, schemaOptions = {}, resolverOptions = {}) =>\n async (values, _, options) => {\n const { transformer, validator } = schemaOptions;\n const data = plainToClass(schema, values, transformer);\n\n const rawErrors = await (resolverOptions.mode === 'sync'\n ? validateSync\n : validate)(data, validator);\n\n if (rawErrors.length) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrors(\n rawErrors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.
|
|
1
|
+
{"version":3,"file":"class-validator.modern.mjs","sources":["../src/class-validator.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { plainToClass } from 'class-transformer';\nimport { ValidationError, validate, validateSync } from 'class-validator';\nimport { FieldErrors } from 'react-hook-form';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ValidationError[],\n validateAllFieldCriteria: boolean,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return errors.reduce((acc, error) => {\n const _path = path ? `${path}.${error.property}` : error.property;\n\n if (error.constraints) {\n const key = Object.keys(error.constraints)[0];\n acc[_path] = {\n type: key,\n message: error.constraints[key],\n };\n\n const _e = acc[_path];\n if (validateAllFieldCriteria && _e) {\n Object.assign(_e, { types: error.constraints });\n }\n }\n\n if (error.children && error.children.length) {\n parseErrors(error.children, validateAllFieldCriteria, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const classValidatorResolver: Resolver =\n (schema, schemaOptions = {}, resolverOptions = {}) =>\n async (values, _, options) => {\n const { transformer, validator } = schemaOptions;\n const data = plainToClass(schema, values, transformer);\n\n const rawErrors = await (resolverOptions.mode === 'sync'\n ? validateSync\n : validate)(data, validator);\n\n if (rawErrors.length) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrors(\n rawErrors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n errors: {},\n };\n };\n"],"names":["parseErrors","errors","validateAllFieldCriteria","parsedErrors","path","reduce","acc","error","_path","property","constraints","key","Object","keys","type","message","_e","assign","types","children","length","classValidatorResolver","schema","schemaOptions","resolverOptions","async","values","_","options","transformer","validator","data","plainToClass","rawErrors","mode","validateSync","validate","toNestErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","raw"],"mappings":"6LAMA,MAAMA,EAAcA,CAClBC,EACAC,EACAC,EAA4B,CAAE,EAC9BC,EAAO,KAEAH,EAAOI,OAAO,CAACC,EAAKC,KACzB,MAAMC,EAAQJ,EAAO,GAAGA,KAAQG,EAAME,WAAaF,EAAME,SAEzD,GAAIF,EAAMG,YAAa,CACrB,MAAMC,EAAMC,OAAOC,KAAKN,EAAMG,aAAa,GAC3CJ,EAAIE,GAAS,CACXM,KAAMH,EACNI,QAASR,EAAMG,YAAYC,IAG7B,MAAMK,EAAKV,EAAIE,GACXN,GAA4Bc,GAC9BJ,OAAOK,OAAOD,EAAI,CAAEE,MAAOX,EAAMG,aAErC,CAMA,OAJIH,EAAMY,UAAYZ,EAAMY,SAASC,QACnCpB,EAAYO,EAAMY,SAAUjB,EAA0BI,EAAKE,GAGtDF,GACNH,GAGQkB,EACXA,CAACC,EAAQC,EAAgB,CAAE,EAAEC,EAAkB,CAAE,IACjDC,MAAOC,EAAQC,EAAGC,KAChB,MAAMC,YAAEA,EAAWC,UAAEA,GAAcP,EAC7BQ,EAAOC,EAAaV,EAAQI,EAAQG,GAEpCI,QAA4C,SAAzBT,EAAgBU,KACrCC,EACAC,GAAUL,EAAMD,GAEpB,OAAIG,EAAUb,OACL,CACLM,OAAQ,CAAE,EACVzB,OAAQoC,EACNrC,EACEiC,GACCL,EAAQU,2BACkB,QAAzBV,EAAQW,cAEZX,KAKNA,EAAQU,2BAA6BE,EAAuB,CAAE,EAAEZ,GAEzD,CACLF,OAAQF,EAAgBiB,IAAM7B,OAAOK,OAAO,GAAIS,GAAUK,EAC1D9B,OAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{plainToClass as t}from"class-transformer";import{validateSync as o,validate as n}from"class-validator";var s=function r(e,t,o,n){return void 0===o&&(o={}),void 0===n&&(n=""),e.reduce(function(e,o){var s=n?n+"."+o.property:o.property;if(o.constraints){var i=Object.keys(o.constraints)[0];e[s]={type:i,message:o.constraints[i]};var a=e[s];t&&a&&Object.assign(a,{types:o.constraints})}return o.children&&o.children.length&&r(o.children,t,e,s),e},o)},i=function(i,a,c){return void 0===a&&(a={}),void 0===c&&(c={}),function(l,
|
|
1
|
+
import{toNestErrors as r,validateFieldsNatively as e}from"@hookform/resolvers";import{plainToClass as t}from"class-transformer";import{validateSync as o,validate as n}from"class-validator";var s=function r(e,t,o,n){return void 0===o&&(o={}),void 0===n&&(n=""),e.reduce(function(e,o){var s=n?n+"."+o.property:o.property;if(o.constraints){var i=Object.keys(o.constraints)[0];e[s]={type:i,message:o.constraints[i]};var a=e[s];t&&a&&Object.assign(a,{types:o.constraints})}return o.children&&o.children.length&&r(o.children,t,e,s),e},o)},i=function(i,a,c){return void 0===a&&(a={}),void 0===c&&(c={}),function(l,v,d){try{var u=a.validator,m=t(i,l,a.transformer);return Promise.resolve(("sync"===c.mode?o:n)(m,u)).then(function(t){return t.length?{values:{},errors:r(s(t,!d.shouldUseNativeValidation&&"all"===d.criteriaMode),d)}:(d.shouldUseNativeValidation&&e({},d),{values:c.raw?Object.assign({},l):m,errors:{}})})}catch(r){return Promise.reject(r)}}};export{i as classValidatorResolver};
|
|
2
2
|
//# sourceMappingURL=class-validator.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-validator.module.js","sources":["../src/class-validator.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { plainToClass } from 'class-transformer';\nimport { ValidationError, validate, validateSync } from 'class-validator';\nimport { FieldErrors } from 'react-hook-form';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ValidationError[],\n validateAllFieldCriteria: boolean,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return errors.reduce((acc, error) => {\n const _path = path ? `${path}.${error.property}` : error.property;\n\n if (error.constraints) {\n const key = Object.keys(error.constraints)[0];\n acc[_path] = {\n type: key,\n message: error.constraints[key],\n };\n\n const _e = acc[_path];\n if (validateAllFieldCriteria && _e) {\n Object.assign(_e, { types: error.constraints });\n }\n }\n\n if (error.children && error.children.length) {\n parseErrors(error.children, validateAllFieldCriteria, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const classValidatorResolver: Resolver =\n (schema, schemaOptions = {}, resolverOptions = {}) =>\n async (values, _, options) => {\n const { transformer, validator } = schemaOptions;\n const data = plainToClass(schema, values, transformer);\n\n const rawErrors = await (resolverOptions.mode === 'sync'\n ? validateSync\n : validate)(data, validator);\n\n if (rawErrors.length) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrors(\n rawErrors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.
|
|
1
|
+
{"version":3,"file":"class-validator.module.js","sources":["../src/class-validator.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport { plainToClass } from 'class-transformer';\nimport { ValidationError, validate, validateSync } from 'class-validator';\nimport { FieldErrors } from 'react-hook-form';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ValidationError[],\n validateAllFieldCriteria: boolean,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return errors.reduce((acc, error) => {\n const _path = path ? `${path}.${error.property}` : error.property;\n\n if (error.constraints) {\n const key = Object.keys(error.constraints)[0];\n acc[_path] = {\n type: key,\n message: error.constraints[key],\n };\n\n const _e = acc[_path];\n if (validateAllFieldCriteria && _e) {\n Object.assign(_e, { types: error.constraints });\n }\n }\n\n if (error.children && error.children.length) {\n parseErrors(error.children, validateAllFieldCriteria, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const classValidatorResolver: Resolver =\n (schema, schemaOptions = {}, resolverOptions = {}) =>\n async (values, _, options) => {\n const { transformer, validator } = schemaOptions;\n const data = plainToClass(schema, values, transformer);\n\n const rawErrors = await (resolverOptions.mode === 'sync'\n ? validateSync\n : validate)(data, validator);\n\n if (rawErrors.length) {\n return {\n values: {},\n errors: toNestErrors(\n parseErrors(\n rawErrors,\n !options.shouldUseNativeValidation &&\n options.criteriaMode === 'all',\n ),\n options,\n ),\n };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return {\n values: resolverOptions.raw ? Object.assign({}, values) : data,\n errors: {},\n };\n };\n"],"names":["parseErrors","errors","validateAllFieldCriteria","parsedErrors","path","reduce","acc","error","_path","property","constraints","key","Object","keys","type","message","_e","assign","types","children","length","classValidatorResolver","schema","schemaOptions","resolverOptions","values","_","options","validator","data","plainToClass","transformer","Promise","resolve","mode","validateSync","validate","then","rawErrors","toNestErrors","shouldUseNativeValidation","criteriaMode","validateFieldsNatively","raw","e","reject"],"mappings":"6LAMA,IAAMA,EAAc,SAAdA,EACJC,EACAC,EACAC,EACAC,GAEA,YAH4B,IAA5BD,IAAAA,EAA4B,CAAE,QAC9BC,IAAAA,IAAAA,EAAO,IAEAH,EAAOI,OAAO,SAACC,EAAKC,GACzB,IAAMC,EAAQJ,EAAUA,MAAQG,EAAME,SAAaF,EAAME,SAEzD,GAAIF,EAAMG,YAAa,CACrB,IAAMC,EAAMC,OAAOC,KAAKN,EAAMG,aAAa,GAC3CJ,EAAIE,GAAS,CACXM,KAAMH,EACNI,QAASR,EAAMG,YAAYC,IAG7B,IAAMK,EAAKV,EAAIE,GACXN,GAA4Bc,GAC9BJ,OAAOK,OAAOD,EAAI,CAAEE,MAAOX,EAAMG,aAErC,CAMA,OAJIH,EAAMY,UAAYZ,EAAMY,SAASC,QACnCpB,EAAYO,EAAMY,SAAUjB,EAA0BI,EAAKE,GAGtDF,CACT,EAAGH,EACL,EAEakB,EACX,SAACC,EAAQC,EAAoBC,eAAP,IAAbD,IAAAA,EAAgB,CAAA,QAAIC,IAAAA,IAAAA,EAAkB,CAAA,YACxCC,EAAQC,EAAGC,OAChB,IAAqBC,EAAcL,EAAdK,UACfC,EAAOC,EAAaR,EAAQG,EADCF,EAA3BQ,aAC+C,OAAAC,QAAAC,SAEL,SAAzBT,EAAgBU,KACrCC,EACAC,GAAUP,EAAMD,IAAUS,KAFxBC,SAAAA,GAIN,OAAIA,EAAUlB,OACL,CACLK,OAAQ,GACRxB,OAAQsC,EACNvC,EACEsC,GACCX,EAAQa,2BACkB,QAAzBb,EAAQc,cAEZd,KAKNA,EAAQa,2BAA6BE,EAAuB,CAAE,EAAEf,GAEzD,CACLF,OAAQD,EAAgBmB,IAAM/B,OAAOK,OAAO,CAAE,EAAEQ,GAAUI,EAC1D5B,OAAQ,CAAA,GACR,EACJ,CAAC,MAAA2C,GAAA,OAAAZ,QAAAa,OAAAD,EAAA,CAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("class-transformer"),require("class-validator")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","class-transformer","class-validator"],r):r((e||self).hookformResolversClassValidator={},e.hookformResolvers,e.classTransformer,e.classValidator)}(this,function(e,r,o,s){var t=function e(r,o,s,t){return void 0===s&&(s={}),void 0===t&&(t=""),r.reduce(function(r,s){var a=t?t+"."+s.property:s.property;if(s.constraints){var i=Object.keys(s.constraints)[0];r[a]={type:i,message:s.constraints[i]};var n=r[a];o&&n&&Object.assign(n,{types:s.constraints})}return s.children&&s.children.length&&e(s.children,o,r,a),r},s)};e.classValidatorResolver=function(e,a,i){return void 0===a&&(a={}),void 0===i&&(i={}),function(n,l,
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@hookform/resolvers"),require("class-transformer"),require("class-validator")):"function"==typeof define&&define.amd?define(["exports","@hookform/resolvers","class-transformer","class-validator"],r):r((e||self).hookformResolversClassValidator={},e.hookformResolvers,e.classTransformer,e.classValidator)}(this,function(e,r,o,s){var t=function e(r,o,s,t){return void 0===s&&(s={}),void 0===t&&(t=""),r.reduce(function(r,s){var a=t?t+"."+s.property:s.property;if(s.constraints){var i=Object.keys(s.constraints)[0];r[a]={type:i,message:s.constraints[i]};var n=r[a];o&&n&&Object.assign(n,{types:s.constraints})}return s.children&&s.children.length&&e(s.children,o,r,a),r},s)};e.classValidatorResolver=function(e,a,i){return void 0===a&&(a={}),void 0===i&&(i={}),function(n,l,c){try{var d=a.validator,f=o.plainToClass(e,n,a.transformer);return Promise.resolve(("sync"===i.mode?s.validateSync:s.validate)(f,d)).then(function(e){return e.length?{values:{},errors:r.toNestErrors(t(e,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)}:(c.shouldUseNativeValidation&&r.validateFieldsNatively({},c),{values:i.raw?Object.assign({},n):f,errors:{}})})}catch(e){return Promise.reject(e)}}}});
|
|
2
2
|
//# sourceMappingURL=class-validator.umd.js.map
|