@hookform/resolvers 3.7.0 → 3.8.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 (252) hide show
  1. package/README.md +69 -0
  2. package/ajv/dist/ajv.js.map +1 -1
  3. package/ajv/dist/ajv.modern.mjs.map +1 -1
  4. package/ajv/dist/ajv.module.js.map +1 -1
  5. package/ajv/dist/ajv.umd.js.map +1 -1
  6. package/ajv/dist/types.d.ts +1 -1
  7. package/ajv/src/__tests__/ajv.ts +7 -1
  8. package/ajv/src/ajv.ts +1 -1
  9. package/ajv/src/types.ts +1 -5
  10. package/arktype/dist/arktype.js +1 -1
  11. package/arktype/dist/arktype.js.map +1 -1
  12. package/arktype/dist/arktype.mjs +1 -1
  13. package/arktype/dist/arktype.modern.mjs +1 -1
  14. package/arktype/dist/arktype.modern.mjs.map +1 -1
  15. package/arktype/dist/arktype.module.js +1 -1
  16. package/arktype/dist/arktype.module.js.map +1 -1
  17. package/arktype/dist/arktype.umd.js +1 -1
  18. package/arktype/dist/arktype.umd.js.map +1 -1
  19. package/arktype/dist/types.d.ts +1 -1
  20. package/arktype/package.json +2 -1
  21. package/arktype/src/__tests__/Form-native-validation.tsx +5 -5
  22. package/arktype/src/__tests__/Form.tsx +2 -2
  23. package/arktype/src/__tests__/__fixtures__/data.ts +1 -1
  24. package/arktype/src/__tests__/__snapshots__/arktype.ts.snap +29 -29
  25. package/arktype/src/__tests__/arktype.ts +1 -1
  26. package/arktype/src/arktype.ts +2 -2
  27. package/arktype/src/types.ts +1 -1
  28. package/class-validator/dist/class-validator.js.map +1 -1
  29. package/class-validator/dist/class-validator.modern.mjs.map +1 -1
  30. package/class-validator/dist/class-validator.module.js.map +1 -1
  31. package/class-validator/dist/class-validator.umd.js.map +1 -1
  32. package/class-validator/dist/types.d.ts +2 -2
  33. package/class-validator/src/__tests__/Form-native-validation.tsx +2 -2
  34. package/class-validator/src/__tests__/Form.tsx +2 -2
  35. package/class-validator/src/__tests__/__snapshots__/class-validator.ts.snap +2 -2
  36. package/class-validator/src/__tests__/class-validator.ts +4 -4
  37. package/class-validator/src/class-validator.ts +2 -2
  38. package/class-validator/src/types.ts +2 -2
  39. package/computed-types/dist/computed-types.js.map +1 -1
  40. package/computed-types/dist/computed-types.modern.mjs.map +1 -1
  41. package/computed-types/dist/computed-types.module.js.map +1 -1
  42. package/computed-types/dist/computed-types.umd.js.map +1 -1
  43. package/computed-types/dist/types.d.ts +1 -1
  44. package/computed-types/src/__tests__/Form-native-validation.tsx +2 -2
  45. package/computed-types/src/__tests__/Form.tsx +2 -2
  46. package/computed-types/src/__tests__/__fixtures__/data.ts +1 -1
  47. package/computed-types/src/__tests__/__snapshots__/computed-types.ts.snap +6 -6
  48. package/computed-types/src/__tests__/computed-types.ts +1 -1
  49. package/computed-types/src/computed-types.ts +2 -2
  50. package/computed-types/src/types.ts +1 -1
  51. package/dist/resolvers.js +1 -1
  52. package/dist/resolvers.js.map +1 -1
  53. package/dist/resolvers.mjs +1 -1
  54. package/dist/resolvers.mjs.map +1 -1
  55. package/dist/resolvers.module.js +1 -1
  56. package/dist/resolvers.module.js.map +1 -1
  57. package/dist/resolvers.umd.js +1 -1
  58. package/dist/resolvers.umd.js.map +1 -1
  59. package/dist/toNestErrors.d.ts +1 -6
  60. package/dist/validateFieldsNatively.d.ts +1 -1
  61. package/effect-ts/dist/effect-ts.js +1 -1
  62. package/effect-ts/dist/effect-ts.js.map +1 -1
  63. package/effect-ts/dist/effect-ts.mjs +1 -1
  64. package/effect-ts/dist/effect-ts.modern.mjs +1 -1
  65. package/effect-ts/dist/effect-ts.modern.mjs.map +1 -1
  66. package/effect-ts/dist/effect-ts.module.js +1 -1
  67. package/effect-ts/dist/effect-ts.module.js.map +1 -1
  68. package/effect-ts/dist/effect-ts.umd.js +1 -1
  69. package/effect-ts/dist/effect-ts.umd.js.map +1 -1
  70. package/effect-ts/src/__tests__/Form-native-validation.tsx +2 -2
  71. package/effect-ts/src/__tests__/Form.tsx +2 -2
  72. package/effect-ts/src/__tests__/__snapshots__/effect-ts.ts.snap +2 -2
  73. package/effect-ts/src/__tests__/effect-ts.ts +1 -1
  74. package/effect-ts/src/effect-ts.ts +1 -1
  75. package/io-ts/dist/errorsToRecord.d.ts +0 -1
  76. package/io-ts/dist/io-ts.js +1 -1
  77. package/io-ts/dist/io-ts.js.map +1 -1
  78. package/io-ts/dist/io-ts.mjs +1 -1
  79. package/io-ts/dist/io-ts.modern.mjs +1 -1
  80. package/io-ts/dist/io-ts.modern.mjs.map +1 -1
  81. package/io-ts/dist/io-ts.module.js +1 -1
  82. package/io-ts/dist/io-ts.module.js.map +1 -1
  83. package/io-ts/dist/io-ts.umd.js +1 -1
  84. package/io-ts/dist/io-ts.umd.js.map +1 -1
  85. package/io-ts/src/__tests__/Form-native-validation.tsx +2 -2
  86. package/io-ts/src/__tests__/Form.tsx +2 -2
  87. package/io-ts/src/__tests__/__snapshots__/io-ts.ts.snap +9 -9
  88. package/io-ts/src/__tests__/errorsToRecord.ts +29 -19
  89. package/io-ts/src/__tests__/io-ts.ts +1 -1
  90. package/io-ts/src/errorsToRecord.ts +19 -10
  91. package/io-ts/src/io-ts.ts +1 -1
  92. package/joi/dist/joi.js +1 -1
  93. package/joi/dist/joi.js.map +1 -1
  94. package/joi/dist/joi.mjs +1 -1
  95. package/joi/dist/joi.modern.mjs +1 -1
  96. package/joi/dist/joi.modern.mjs.map +1 -1
  97. package/joi/dist/joi.module.js +1 -1
  98. package/joi/dist/joi.module.js.map +1 -1
  99. package/joi/dist/joi.umd.js +1 -1
  100. package/joi/dist/joi.umd.js.map +1 -1
  101. package/joi/dist/types.d.ts +1 -1
  102. package/joi/src/__tests__/Form-native-validation.tsx +2 -2
  103. package/joi/src/__tests__/Form.tsx +2 -2
  104. package/joi/src/__tests__/__snapshots__/joi.ts.snap +56 -56
  105. package/joi/src/__tests__/joi.ts +1 -1
  106. package/joi/src/joi.ts +1 -1
  107. package/joi/src/types.ts +1 -5
  108. package/nope/dist/nope.js.map +1 -1
  109. package/nope/dist/nope.modern.mjs.map +1 -1
  110. package/nope/dist/nope.module.js.map +1 -1
  111. package/nope/dist/nope.umd.js.map +1 -1
  112. package/nope/dist/types.d.ts +1 -1
  113. package/nope/src/__tests__/Form-native-validation.tsx +2 -2
  114. package/nope/src/__tests__/Form.tsx +2 -2
  115. package/nope/src/__tests__/__fixtures__/data.ts +1 -1
  116. package/nope/src/__tests__/nope.ts +1 -1
  117. package/nope/src/nope.ts +1 -1
  118. package/nope/src/types.ts +2 -2
  119. package/package.json +54 -51
  120. package/superstruct/dist/superstruct.js.map +1 -1
  121. package/superstruct/dist/superstruct.modern.mjs.map +1 -1
  122. package/superstruct/dist/superstruct.module.js.map +1 -1
  123. package/superstruct/dist/superstruct.umd.js.map +1 -1
  124. package/superstruct/dist/types.d.ts +1 -1
  125. package/superstruct/src/__tests__/Form-native-validation.tsx +2 -2
  126. package/superstruct/src/__tests__/Form.tsx +2 -2
  127. package/superstruct/src/__tests__/__fixtures__/data.ts +8 -8
  128. package/superstruct/src/__tests__/__snapshots__/superstruct.ts.snap +4 -4
  129. package/superstruct/src/__tests__/superstruct.ts +1 -1
  130. package/superstruct/src/superstruct.ts +1 -1
  131. package/superstruct/src/types.ts +1 -1
  132. package/typanion/dist/typanion.js.map +1 -1
  133. package/typanion/dist/typanion.modern.mjs.map +1 -1
  134. package/typanion/dist/typanion.module.js.map +1 -1
  135. package/typanion/dist/typanion.umd.js.map +1 -1
  136. package/typanion/dist/types.d.ts +1 -1
  137. package/typanion/src/__tests__/Form-native-validation.tsx +1 -1
  138. package/typanion/src/__tests__/Form.tsx +1 -1
  139. package/typanion/src/__tests__/__fixtures__/data.ts +12 -7
  140. package/typanion/src/__tests__/__snapshots__/typanion.ts.snap +4 -4
  141. package/typanion/src/__tests__/typanion.ts +1 -1
  142. package/typanion/src/typanion.ts +1 -1
  143. package/typanion/src/types.ts +4 -4
  144. package/typebox/dist/typebox.js +1 -1
  145. package/typebox/dist/typebox.js.map +1 -1
  146. package/typebox/dist/typebox.mjs +1 -1
  147. package/typebox/dist/typebox.modern.mjs +1 -1
  148. package/typebox/dist/typebox.modern.mjs.map +1 -1
  149. package/typebox/dist/typebox.module.js +1 -1
  150. package/typebox/dist/typebox.module.js.map +1 -1
  151. package/typebox/dist/typebox.umd.js +1 -1
  152. package/typebox/dist/typebox.umd.js.map +1 -1
  153. package/typebox/dist/types.d.ts +3 -2
  154. package/typebox/src/__tests__/Form-compiler.tsx +57 -0
  155. package/typebox/src/__tests__/Form-native-validation-compiler.tsx +86 -0
  156. package/typebox/src/__tests__/Form-native-validation.tsx +4 -4
  157. package/typebox/src/__tests__/Form.tsx +3 -3
  158. package/typebox/src/__tests__/__fixtures__/data.ts +6 -2
  159. package/typebox/src/__tests__/__snapshots__/typebox-compiler.ts.snap +188 -0
  160. package/typebox/src/__tests__/__snapshots__/typebox.ts.snap +13 -13
  161. package/typebox/src/__tests__/typebox-compiler.ts +37 -0
  162. package/typebox/src/__tests__/typebox.ts +1 -1
  163. package/typebox/src/typebox.ts +8 -3
  164. package/typebox/src/types.ts +3 -2
  165. package/typeschema/dist/index.d.ts +2 -0
  166. package/typeschema/dist/types.d.ts +9 -0
  167. package/typeschema/dist/typeschema.d.ts +2 -0
  168. package/typeschema/dist/typeschema.js +2 -0
  169. package/typeschema/dist/typeschema.js.map +1 -0
  170. package/typeschema/dist/typeschema.mjs +2 -0
  171. package/typeschema/dist/typeschema.modern.mjs +2 -0
  172. package/typeschema/dist/typeschema.modern.mjs.map +1 -0
  173. package/typeschema/dist/typeschema.module.js +2 -0
  174. package/typeschema/dist/typeschema.module.js.map +1 -0
  175. package/typeschema/dist/typeschema.umd.js +2 -0
  176. package/typeschema/dist/typeschema.umd.js.map +1 -0
  177. package/typeschema/package.json +18 -0
  178. package/typeschema/src/__tests__/Form-native-validation.tsx +82 -0
  179. package/typeschema/src/__tests__/Form.tsx +53 -0
  180. package/typeschema/src/__tests__/__fixtures__/data.ts +88 -0
  181. package/typeschema/src/__tests__/__snapshots__/typeschema.ts.snap +225 -0
  182. package/typeschema/src/__tests__/typeschema.ts +70 -0
  183. package/typeschema/src/index.ts +2 -0
  184. package/typeschema/src/types.ts +18 -0
  185. package/typeschema/src/typeschema.ts +70 -0
  186. package/valibot/dist/types.d.ts +1 -1
  187. package/valibot/dist/valibot.js +1 -1
  188. package/valibot/dist/valibot.js.map +1 -1
  189. package/valibot/dist/valibot.mjs +1 -1
  190. package/valibot/dist/valibot.modern.mjs +1 -1
  191. package/valibot/dist/valibot.modern.mjs.map +1 -1
  192. package/valibot/dist/valibot.module.js +1 -1
  193. package/valibot/dist/valibot.module.js.map +1 -1
  194. package/valibot/dist/valibot.umd.js +1 -1
  195. package/valibot/dist/valibot.umd.js.map +1 -1
  196. package/valibot/src/__tests__/Form-native-validation.tsx +2 -2
  197. package/valibot/src/__tests__/Form.tsx +1 -1
  198. package/valibot/src/__tests__/valibot.ts +4 -4
  199. package/valibot/src/types.ts +1 -1
  200. package/valibot/src/valibot.ts +12 -6
  201. package/vest/dist/types.d.ts +2 -2
  202. package/vest/dist/vest.js.map +1 -1
  203. package/vest/dist/vest.modern.mjs.map +1 -1
  204. package/vest/dist/vest.module.js.map +1 -1
  205. package/vest/dist/vest.umd.js.map +1 -1
  206. package/vest/src/__tests__/Form-native-validation.tsx +1 -1
  207. package/vest/src/__tests__/Form.tsx +1 -1
  208. package/vest/src/__tests__/__snapshots__/vest.ts.snap +0 -6
  209. package/vest/src/__tests__/vest.ts +14 -8
  210. package/vest/src/types.ts +11 -4
  211. package/vest/src/vest.ts +1 -1
  212. package/vine/dist/types.d.ts +1 -1
  213. package/vine/dist/vine.js +1 -1
  214. package/vine/dist/vine.js.map +1 -1
  215. package/vine/dist/vine.mjs +1 -1
  216. package/vine/dist/vine.modern.mjs +1 -1
  217. package/vine/dist/vine.modern.mjs.map +1 -1
  218. package/vine/dist/vine.module.js +1 -1
  219. package/vine/dist/vine.module.js.map +1 -1
  220. package/vine/dist/vine.umd.js +1 -1
  221. package/vine/dist/vine.umd.js.map +1 -1
  222. package/vine/src/__tests__/Form-native-validation.tsx +9 -5
  223. package/vine/src/__tests__/Form.tsx +9 -5
  224. package/vine/src/__tests__/__fixtures__/data.ts +4 -2
  225. package/vine/src/__tests__/vine.ts +1 -1
  226. package/vine/src/types.ts +1 -1
  227. package/vine/src/vine.ts +10 -8
  228. package/yup/dist/yup.d.ts +1 -1
  229. package/yup/dist/yup.js.map +1 -1
  230. package/yup/dist/yup.modern.mjs.map +1 -1
  231. package/yup/dist/yup.module.js.map +1 -1
  232. package/yup/dist/yup.umd.js.map +1 -1
  233. package/yup/src/__tests__/Form-native-validation.tsx +1 -1
  234. package/yup/src/__tests__/Form.tsx +1 -1
  235. package/yup/src/__tests__/__snapshots__/yup.ts.snap +13 -13
  236. package/yup/src/__tests__/yup.ts +9 -7
  237. package/yup/src/yup.ts +2 -2
  238. package/zod/dist/types.d.ts +1 -1
  239. package/zod/dist/zod.js +1 -1
  240. package/zod/dist/zod.js.map +1 -1
  241. package/zod/dist/zod.mjs +1 -1
  242. package/zod/dist/zod.modern.mjs +1 -1
  243. package/zod/dist/zod.modern.mjs.map +1 -1
  244. package/zod/dist/zod.module.js +1 -1
  245. package/zod/dist/zod.module.js.map +1 -1
  246. package/zod/dist/zod.umd.js +1 -1
  247. package/zod/dist/zod.umd.js.map +1 -1
  248. package/zod/src/__tests__/Form-native-validation.tsx +2 -2
  249. package/zod/src/__tests__/Form.tsx +1 -1
  250. package/zod/src/__tests__/zod.ts +1 -1
  251. package/zod/src/types.ts +1 -1
  252. package/zod/src/zod.ts +4 -3
@@ -4,50 +4,50 @@ exports[`joiResolver > should return a single error from joiResolver when valida
4
4
  {
5
5
  "errors": {
6
6
  "birthYear": {
7
- "message": "\\"birthYear\\" must be a number",
7
+ "message": ""birthYear" must be a number",
8
8
  "ref": undefined,
9
9
  "type": "number.base",
10
10
  },
11
11
  "email": {
12
- "message": "\\"email\\" is not allowed to be empty",
12
+ "message": ""email" is not allowed to be empty",
13
13
  "ref": {
14
14
  "name": "email",
15
15
  },
16
16
  "type": "string.empty",
17
17
  },
18
18
  "enabled": {
19
- "message": "\\"enabled\\" is required",
19
+ "message": ""enabled" is required",
20
20
  "ref": undefined,
21
21
  "type": "any.required",
22
22
  },
23
23
  "like": [
24
24
  {
25
25
  "id": {
26
- "message": "\\"like[0].id\\" must be a number",
26
+ "message": ""like[0].id" must be a number",
27
27
  "ref": undefined,
28
28
  "type": "number.base",
29
29
  },
30
30
  "name": {
31
- "message": "\\"like[0].name\\" length must be 4 characters long",
31
+ "message": ""like[0].name" length must be 4 characters long",
32
32
  "ref": undefined,
33
33
  "type": "string.length",
34
34
  },
35
35
  },
36
36
  ],
37
37
  "password": {
38
- "message": "\\"password\\" with value \\"___\\" fails to match the One uppercase character pattern",
38
+ "message": ""password" with value "___" fails to match the One uppercase character pattern",
39
39
  "ref": {
40
40
  "name": "password",
41
41
  },
42
42
  "type": "string.pattern.name",
43
43
  },
44
44
  "tags": {
45
- "message": "\\"tags\\" is required",
45
+ "message": ""tags" is required",
46
46
  "ref": undefined,
47
47
  "type": "any.required",
48
48
  },
49
49
  "username": {
50
- "message": "\\"username\\" is required",
50
+ "message": ""username" is required",
51
51
  "ref": {
52
52
  "name": "username",
53
53
  },
@@ -62,50 +62,50 @@ exports[`joiResolver > should return a single error from joiResolver with \`mode
62
62
  {
63
63
  "errors": {
64
64
  "birthYear": {
65
- "message": "\\"birthYear\\" must be a number",
65
+ "message": ""birthYear" must be a number",
66
66
  "ref": undefined,
67
67
  "type": "number.base",
68
68
  },
69
69
  "email": {
70
- "message": "\\"email\\" is not allowed to be empty",
70
+ "message": ""email" is not allowed to be empty",
71
71
  "ref": {
72
72
  "name": "email",
73
73
  },
74
74
  "type": "string.empty",
75
75
  },
76
76
  "enabled": {
77
- "message": "\\"enabled\\" is required",
77
+ "message": ""enabled" is required",
78
78
  "ref": undefined,
79
79
  "type": "any.required",
80
80
  },
81
81
  "like": [
82
82
  {
83
83
  "id": {
84
- "message": "\\"like[0].id\\" must be a number",
84
+ "message": ""like[0].id" must be a number",
85
85
  "ref": undefined,
86
86
  "type": "number.base",
87
87
  },
88
88
  "name": {
89
- "message": "\\"like[0].name\\" length must be 4 characters long",
89
+ "message": ""like[0].name" length must be 4 characters long",
90
90
  "ref": undefined,
91
91
  "type": "string.length",
92
92
  },
93
93
  },
94
94
  ],
95
95
  "password": {
96
- "message": "\\"password\\" with value \\"___\\" fails to match the One uppercase character pattern",
96
+ "message": ""password" with value "___" fails to match the One uppercase character pattern",
97
97
  "ref": {
98
98
  "name": "password",
99
99
  },
100
100
  "type": "string.pattern.name",
101
101
  },
102
102
  "tags": {
103
- "message": "\\"tags\\" is required",
103
+ "message": ""tags" is required",
104
104
  "ref": undefined,
105
105
  "type": "any.required",
106
106
  },
107
107
  "username": {
108
- "message": "\\"username\\" is required",
108
+ "message": ""username" is required",
109
109
  "ref": {
110
110
  "name": "username",
111
111
  },
@@ -120,83 +120,83 @@ exports[`joiResolver > should return all the errors from joiResolver when valida
120
120
  {
121
121
  "errors": {
122
122
  "birthYear": {
123
- "message": "\\"birthYear\\" must be a number",
123
+ "message": ""birthYear" must be a number",
124
124
  "ref": undefined,
125
125
  "type": "number.base",
126
126
  "types": {
127
- "number.base": "\\"birthYear\\" must be a number",
127
+ "number.base": ""birthYear" must be a number",
128
128
  },
129
129
  },
130
130
  "email": {
131
- "message": "\\"email\\" is not allowed to be empty",
131
+ "message": ""email" is not allowed to be empty",
132
132
  "ref": {
133
133
  "name": "email",
134
134
  },
135
135
  "type": "string.empty",
136
136
  "types": {
137
- "string.empty": "\\"email\\" is not allowed to be empty",
137
+ "string.empty": ""email" is not allowed to be empty",
138
138
  },
139
139
  },
140
140
  "enabled": {
141
- "message": "\\"enabled\\" is required",
141
+ "message": ""enabled" is required",
142
142
  "ref": undefined,
143
143
  "type": "any.required",
144
144
  "types": {
145
- "any.required": "\\"enabled\\" is required",
145
+ "any.required": ""enabled" is required",
146
146
  },
147
147
  },
148
148
  "like": [
149
149
  {
150
150
  "id": {
151
- "message": "\\"like[0].id\\" must be a number",
151
+ "message": ""like[0].id" must be a number",
152
152
  "ref": undefined,
153
153
  "type": "number.base",
154
154
  "types": {
155
- "number.base": "\\"like[0].id\\" must be a number",
155
+ "number.base": ""like[0].id" must be a number",
156
156
  },
157
157
  },
158
158
  "name": {
159
- "message": "\\"like[0].name\\" length must be 4 characters long",
159
+ "message": ""like[0].name" length must be 4 characters long",
160
160
  "ref": undefined,
161
161
  "type": "string.length",
162
162
  "types": {
163
- "string.length": "\\"like[0].name\\" length must be 4 characters long",
164
- "string.pattern.base": "\\"like[0].name\\" with value \\"r\\" fails to match the required pattern: /a/",
163
+ "string.length": ""like[0].name" length must be 4 characters long",
164
+ "string.pattern.base": ""like[0].name" with value "r" fails to match the required pattern: /a/",
165
165
  },
166
166
  },
167
167
  },
168
168
  ],
169
169
  "password": {
170
- "message": "\\"password\\" with value \\"___\\" fails to match the One uppercase character pattern",
170
+ "message": ""password" with value "___" fails to match the One uppercase character pattern",
171
171
  "ref": {
172
172
  "name": "password",
173
173
  },
174
174
  "type": "string.pattern.name",
175
175
  "types": {
176
- "string.min": "\\"password\\" length must be at least 8 characters long",
176
+ "string.min": ""password" length must be at least 8 characters long",
177
177
  "string.pattern.name": [
178
- "\\"password\\" with value \\"___\\" fails to match the One uppercase character pattern",
179
- "\\"password\\" with value \\"___\\" fails to match the One lowercase character pattern",
180
- "\\"password\\" with value \\"___\\" fails to match the One number pattern",
178
+ ""password" with value "___" fails to match the One uppercase character pattern",
179
+ ""password" with value "___" fails to match the One lowercase character pattern",
180
+ ""password" with value "___" fails to match the One number pattern",
181
181
  ],
182
182
  },
183
183
  },
184
184
  "tags": {
185
- "message": "\\"tags\\" is required",
185
+ "message": ""tags" is required",
186
186
  "ref": undefined,
187
187
  "type": "any.required",
188
188
  "types": {
189
- "any.required": "\\"tags\\" is required",
189
+ "any.required": ""tags" is required",
190
190
  },
191
191
  },
192
192
  "username": {
193
- "message": "\\"username\\" is required",
193
+ "message": ""username" is required",
194
194
  "ref": {
195
195
  "name": "username",
196
196
  },
197
197
  "type": "any.required",
198
198
  "types": {
199
- "any.required": "\\"username\\" is required",
199
+ "any.required": ""username" is required",
200
200
  },
201
201
  },
202
202
  },
@@ -208,83 +208,83 @@ exports[`joiResolver > should return all the errors from joiResolver when valida
208
208
  {
209
209
  "errors": {
210
210
  "birthYear": {
211
- "message": "\\"birthYear\\" must be a number",
211
+ "message": ""birthYear" must be a number",
212
212
  "ref": undefined,
213
213
  "type": "number.base",
214
214
  "types": {
215
- "number.base": "\\"birthYear\\" must be a number",
215
+ "number.base": ""birthYear" must be a number",
216
216
  },
217
217
  },
218
218
  "email": {
219
- "message": "\\"email\\" is not allowed to be empty",
219
+ "message": ""email" is not allowed to be empty",
220
220
  "ref": {
221
221
  "name": "email",
222
222
  },
223
223
  "type": "string.empty",
224
224
  "types": {
225
- "string.empty": "\\"email\\" is not allowed to be empty",
225
+ "string.empty": ""email" is not allowed to be empty",
226
226
  },
227
227
  },
228
228
  "enabled": {
229
- "message": "\\"enabled\\" is required",
229
+ "message": ""enabled" is required",
230
230
  "ref": undefined,
231
231
  "type": "any.required",
232
232
  "types": {
233
- "any.required": "\\"enabled\\" is required",
233
+ "any.required": ""enabled" is required",
234
234
  },
235
235
  },
236
236
  "like": [
237
237
  {
238
238
  "id": {
239
- "message": "\\"like[0].id\\" must be a number",
239
+ "message": ""like[0].id" must be a number",
240
240
  "ref": undefined,
241
241
  "type": "number.base",
242
242
  "types": {
243
- "number.base": "\\"like[0].id\\" must be a number",
243
+ "number.base": ""like[0].id" must be a number",
244
244
  },
245
245
  },
246
246
  "name": {
247
- "message": "\\"like[0].name\\" length must be 4 characters long",
247
+ "message": ""like[0].name" length must be 4 characters long",
248
248
  "ref": undefined,
249
249
  "type": "string.length",
250
250
  "types": {
251
- "string.length": "\\"like[0].name\\" length must be 4 characters long",
252
- "string.pattern.base": "\\"like[0].name\\" with value \\"r\\" fails to match the required pattern: /a/",
251
+ "string.length": ""like[0].name" length must be 4 characters long",
252
+ "string.pattern.base": ""like[0].name" with value "r" fails to match the required pattern: /a/",
253
253
  },
254
254
  },
255
255
  },
256
256
  ],
257
257
  "password": {
258
- "message": "\\"password\\" with value \\"___\\" fails to match the One uppercase character pattern",
258
+ "message": ""password" with value "___" fails to match the One uppercase character pattern",
259
259
  "ref": {
260
260
  "name": "password",
261
261
  },
262
262
  "type": "string.pattern.name",
263
263
  "types": {
264
- "string.min": "\\"password\\" length must be at least 8 characters long",
264
+ "string.min": ""password" length must be at least 8 characters long",
265
265
  "string.pattern.name": [
266
- "\\"password\\" with value \\"___\\" fails to match the One uppercase character pattern",
267
- "\\"password\\" with value \\"___\\" fails to match the One lowercase character pattern",
268
- "\\"password\\" with value \\"___\\" fails to match the One number pattern",
266
+ ""password" with value "___" fails to match the One uppercase character pattern",
267
+ ""password" with value "___" fails to match the One lowercase character pattern",
268
+ ""password" with value "___" fails to match the One number pattern",
269
269
  ],
270
270
  },
271
271
  },
272
272
  "tags": {
273
- "message": "\\"tags\\" is required",
273
+ "message": ""tags" is required",
274
274
  "ref": undefined,
275
275
  "type": "any.required",
276
276
  "types": {
277
- "any.required": "\\"tags\\" is required",
277
+ "any.required": ""tags" is required",
278
278
  },
279
279
  },
280
280
  "username": {
281
- "message": "\\"username\\" is required",
281
+ "message": ""username" is required",
282
282
  "ref": {
283
283
  "name": "username",
284
284
  },
285
285
  "type": "any.required",
286
286
  "types": {
287
- "any.required": "\\"username\\" is required",
287
+ "any.required": ""username" is required",
288
288
  },
289
289
  },
290
290
  },
@@ -1,5 +1,5 @@
1
1
  import { joiResolver } from '..';
2
- import { schema, validData, fields, invalidData } from './__fixtures__/data';
2
+ import { fields, invalidData, schema, validData } from './__fixtures__/data';
3
3
 
4
4
  const shouldUseNativeValidation = false;
5
5
 
package/joi/src/joi.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { appendErrors, FieldError } from 'react-hook-form';
2
1
  import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';
3
2
  import type { ValidationError } from 'joi';
3
+ import { FieldError, appendErrors } from 'react-hook-form';
4
4
  import { Resolver } from './types';
5
5
 
6
6
  const parseErrorSchema = (
package/joi/src/types.ts CHANGED
@@ -1,9 +1,5 @@
1
- import {
2
- FieldValues,
3
- ResolverOptions,
4
- ResolverResult,
5
- } from 'react-hook-form';
6
1
  import type { AsyncValidationOptions, Schema } from 'joi';
2
+ import { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
7
3
 
8
4
  export type Resolver = <T extends Schema>(
9
5
  schema: T,
@@ -1 +1 @@
1
- {"version":3,"file":"nope.js","sources":["../src/nope.ts"],"sourcesContent":["import type { FieldError, FieldErrors } from 'react-hook-form';\nimport { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport type { ShapeErrors } from 'nope-validator/lib/cjs/types';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ShapeErrors,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return Object.keys(errors).reduce((acc, key) => {\n const _path = path ? `${path}.${key}` : key;\n const error = errors[key];\n\n if (typeof error === 'string') {\n acc[_path] = {\n message: error,\n } as FieldError;\n } else {\n parseErrors(error, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const nopeResolver: Resolver =\n (\n schema,\n schemaOptions = {\n abortEarly: false,\n },\n ) =>\n (values, context, options) => {\n const result = schema.validate(values, context, schemaOptions) as\n | ShapeErrors\n | undefined;\n\n if (result) {\n return { values: {}, errors: toNestErrors(parseErrors(result), options) };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrors","errors","parsedErrors","path","Object","keys","reduce","acc","key","_path","error","message","schema","schemaOptions","abortEarly","values","context","options","result","validate","toNestErrors","shouldUseNativeValidation","validateFieldsNatively"],"mappings":"qCAKMA,EAAc,SAAdA,EACJC,EACAC,EACAC,GAEA,YAHAD,IAAAA,IAAAA,EAA4B,CAAE,QAC1B,IAAJC,IAAAA,EAAO,IAEAC,OAAOC,KAAKJ,GAAQK,OAAO,SAACC,EAAKC,GACtC,IAAMC,EAAQN,EAAUA,EAAI,IAAIK,EAAQA,EAClCE,EAAQT,EAAOO,GAUrB,MARqB,iBAAVE,EACTH,EAAIE,GAAS,CACXE,QAASD,GAGXV,EAAYU,EAAOH,EAAKE,GAGnBF,CACT,EAAGL,EACL,uBAGE,SACEU,EACAC,GAEC,YAFY,IAAbA,IAAAA,EAAgB,CACdC,YAAY,aAGfC,EAAQC,EAASC,GAChB,IAAMC,EAASN,EAAOO,SAASJ,EAAQC,EAASH,GAIhD,OAAIK,EACK,CAAEH,OAAQ,CAAE,EAAEd,OAAQmB,EAAAA,aAAapB,EAAYkB,GAASD,KAGjEA,EAAQI,2BAA6BC,EAAsBA,uBAAC,CAAE,EAAEL,GAEzD,CAAEF,OAAAA,EAAQd,OAAQ,IAC3B,CAAC"}
1
+ {"version":3,"file":"nope.js","sources":["../src/nope.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport type { ShapeErrors } from 'nope-validator/lib/cjs/types';\nimport type { FieldError, FieldErrors } from 'react-hook-form';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ShapeErrors,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return Object.keys(errors).reduce((acc, key) => {\n const _path = path ? `${path}.${key}` : key;\n const error = errors[key];\n\n if (typeof error === 'string') {\n acc[_path] = {\n message: error,\n } as FieldError;\n } else {\n parseErrors(error, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const nopeResolver: Resolver =\n (\n schema,\n schemaOptions = {\n abortEarly: false,\n },\n ) =>\n (values, context, options) => {\n const result = schema.validate(values, context, schemaOptions) as\n | ShapeErrors\n | undefined;\n\n if (result) {\n return { values: {}, errors: toNestErrors(parseErrors(result), options) };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrors","errors","parsedErrors","path","Object","keys","reduce","acc","key","_path","error","message","schema","schemaOptions","abortEarly","values","context","options","result","validate","toNestErrors","shouldUseNativeValidation","validateFieldsNatively"],"mappings":"qCAKMA,EAAc,SAAdA,EACJC,EACAC,EACAC,GAEA,YAHAD,IAAAA,IAAAA,EAA4B,CAAE,QAC1B,IAAJC,IAAAA,EAAO,IAEAC,OAAOC,KAAKJ,GAAQK,OAAO,SAACC,EAAKC,GACtC,IAAMC,EAAQN,EAAUA,EAAI,IAAIK,EAAQA,EAClCE,EAAQT,EAAOO,GAUrB,MARqB,iBAAVE,EACTH,EAAIE,GAAS,CACXE,QAASD,GAGXV,EAAYU,EAAOH,EAAKE,GAGnBF,CACT,EAAGL,EACL,uBAGE,SACEU,EACAC,GAEC,YAFY,IAAbA,IAAAA,EAAgB,CACdC,YAAY,aAGfC,EAAQC,EAASC,GAChB,IAAMC,EAASN,EAAOO,SAASJ,EAAQC,EAASH,GAIhD,OAAIK,EACK,CAAEH,OAAQ,CAAE,EAAEd,OAAQmB,EAAAA,aAAapB,EAAYkB,GAASD,KAGjEA,EAAQI,2BAA6BC,EAAsBA,uBAAC,CAAE,EAAEL,GAEzD,CAAEF,OAAAA,EAAQd,OAAQ,IAC3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"nope.modern.mjs","sources":["../src/nope.ts"],"sourcesContent":["import type { FieldError, FieldErrors } from 'react-hook-form';\nimport { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport type { ShapeErrors } from 'nope-validator/lib/cjs/types';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ShapeErrors,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return Object.keys(errors).reduce((acc, key) => {\n const _path = path ? `${path}.${key}` : key;\n const error = errors[key];\n\n if (typeof error === 'string') {\n acc[_path] = {\n message: error,\n } as FieldError;\n } else {\n parseErrors(error, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const nopeResolver: Resolver =\n (\n schema,\n schemaOptions = {\n abortEarly: false,\n },\n ) =>\n (values, context, options) => {\n const result = schema.validate(values, context, schemaOptions) as\n | ShapeErrors\n | undefined;\n\n if (result) {\n return { values: {}, errors: toNestErrors(parseErrors(result), options) };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrors","errors","parsedErrors","path","Object","keys","reduce","acc","key","_path","error","message","nopeResolver","schema","schemaOptions","abortEarly","values","context","options","result","validate","toNestErrors","shouldUseNativeValidation","validateFieldsNatively"],"mappings":"+EAKA,MAAMA,EAAcA,CAClBC,EACAC,EAA4B,CAAA,EAC5BC,EAAO,KAEAC,OAAOC,KAAKJ,GAAQK,OAAO,CAACC,EAAKC,KACtC,MAAMC,EAAQN,EAAO,GAAGA,KAAQK,IAAQA,EAClCE,EAAQT,EAAOO,GAUrB,MARqB,iBAAVE,EACTH,EAAIE,GAAS,CACXE,QAASD,GAGXV,EAAYU,EAAOH,EAAKE,GAGnBF,GACNL,GAGQU,EACXA,CACEC,EACAC,EAAgB,CACdC,YAAY,KAGhB,CAACC,EAAQC,EAASC,KAChB,MAAMC,EAASN,EAAOO,SAASJ,EAAQC,EAASH,GAIhD,OAAIK,EACK,CAAEH,OAAQ,CAAE,EAAEf,OAAQoB,EAAarB,EAAYmB,GAASD,KAGjEA,EAAQI,2BAA6BC,EAAuB,GAAIL,GAEzD,CAAEF,SAAQf,OAAQ"}
1
+ {"version":3,"file":"nope.modern.mjs","sources":["../src/nope.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport type { ShapeErrors } from 'nope-validator/lib/cjs/types';\nimport type { FieldError, FieldErrors } from 'react-hook-form';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ShapeErrors,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return Object.keys(errors).reduce((acc, key) => {\n const _path = path ? `${path}.${key}` : key;\n const error = errors[key];\n\n if (typeof error === 'string') {\n acc[_path] = {\n message: error,\n } as FieldError;\n } else {\n parseErrors(error, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const nopeResolver: Resolver =\n (\n schema,\n schemaOptions = {\n abortEarly: false,\n },\n ) =>\n (values, context, options) => {\n const result = schema.validate(values, context, schemaOptions) as\n | ShapeErrors\n | undefined;\n\n if (result) {\n return { values: {}, errors: toNestErrors(parseErrors(result), options) };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrors","errors","parsedErrors","path","Object","keys","reduce","acc","key","_path","error","message","nopeResolver","schema","schemaOptions","abortEarly","values","context","options","result","validate","toNestErrors","shouldUseNativeValidation","validateFieldsNatively"],"mappings":"+EAKA,MAAMA,EAAcA,CAClBC,EACAC,EAA4B,CAAA,EAC5BC,EAAO,KAEAC,OAAOC,KAAKJ,GAAQK,OAAO,CAACC,EAAKC,KACtC,MAAMC,EAAQN,EAAO,GAAGA,KAAQK,IAAQA,EAClCE,EAAQT,EAAOO,GAUrB,MARqB,iBAAVE,EACTH,EAAIE,GAAS,CACXE,QAASD,GAGXV,EAAYU,EAAOH,EAAKE,GAGnBF,GACNL,GAGQU,EACXA,CACEC,EACAC,EAAgB,CACdC,YAAY,KAGhB,CAACC,EAAQC,EAASC,KAChB,MAAMC,EAASN,EAAOO,SAASJ,EAAQC,EAASH,GAIhD,OAAIK,EACK,CAAEH,OAAQ,CAAE,EAAEf,OAAQoB,EAAarB,EAAYmB,GAASD,KAGjEA,EAAQI,2BAA6BC,EAAuB,GAAIL,GAEzD,CAAEF,SAAQf,OAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"nope.module.js","sources":["../src/nope.ts"],"sourcesContent":["import type { FieldError, FieldErrors } from 'react-hook-form';\nimport { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport type { ShapeErrors } from 'nope-validator/lib/cjs/types';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ShapeErrors,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return Object.keys(errors).reduce((acc, key) => {\n const _path = path ? `${path}.${key}` : key;\n const error = errors[key];\n\n if (typeof error === 'string') {\n acc[_path] = {\n message: error,\n } as FieldError;\n } else {\n parseErrors(error, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const nopeResolver: Resolver =\n (\n schema,\n schemaOptions = {\n abortEarly: false,\n },\n ) =>\n (values, context, options) => {\n const result = schema.validate(values, context, schemaOptions) as\n | ShapeErrors\n | undefined;\n\n if (result) {\n return { values: {}, errors: toNestErrors(parseErrors(result), options) };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrors","errors","parsedErrors","path","Object","keys","reduce","acc","key","_path","error","message","nopeResolver","schema","schemaOptions","abortEarly","values","context","options","result","validate","toNestErrors","shouldUseNativeValidation","validateFieldsNatively"],"mappings":"+EAKA,IAAMA,EAAc,SAAdA,EACJC,EACAC,EACAC,GAEA,YAHAD,IAAAA,IAAAA,EAA4B,CAAE,QAC1B,IAAJC,IAAAA,EAAO,IAEAC,OAAOC,KAAKJ,GAAQK,OAAO,SAACC,EAAKC,GACtC,IAAMC,EAAQN,EAAUA,EAAI,IAAIK,EAAQA,EAClCE,EAAQT,EAAOO,GAUrB,MARqB,iBAAVE,EACTH,EAAIE,GAAS,CACXE,QAASD,GAGXV,EAAYU,EAAOH,EAAKE,GAGnBF,CACT,EAAGL,EACL,EAEaU,EACX,SACEC,EACAC,GAEC,YAFY,IAAbA,IAAAA,EAAgB,CACdC,YAAY,aAGfC,EAAQC,EAASC,GAChB,IAAMC,EAASN,EAAOO,SAASJ,EAAQC,EAASH,GAIhD,OAAIK,EACK,CAAEH,OAAQ,CAAE,EAAEf,OAAQoB,EAAarB,EAAYmB,GAASD,KAGjEA,EAAQI,2BAA6BC,EAAuB,CAAE,EAAEL,GAEzD,CAAEF,OAAAA,EAAQf,OAAQ,IAC3B,CAAC"}
1
+ {"version":3,"file":"nope.module.js","sources":["../src/nope.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport type { ShapeErrors } from 'nope-validator/lib/cjs/types';\nimport type { FieldError, FieldErrors } from 'react-hook-form';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ShapeErrors,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return Object.keys(errors).reduce((acc, key) => {\n const _path = path ? `${path}.${key}` : key;\n const error = errors[key];\n\n if (typeof error === 'string') {\n acc[_path] = {\n message: error,\n } as FieldError;\n } else {\n parseErrors(error, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const nopeResolver: Resolver =\n (\n schema,\n schemaOptions = {\n abortEarly: false,\n },\n ) =>\n (values, context, options) => {\n const result = schema.validate(values, context, schemaOptions) as\n | ShapeErrors\n | undefined;\n\n if (result) {\n return { values: {}, errors: toNestErrors(parseErrors(result), options) };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrors","errors","parsedErrors","path","Object","keys","reduce","acc","key","_path","error","message","nopeResolver","schema","schemaOptions","abortEarly","values","context","options","result","validate","toNestErrors","shouldUseNativeValidation","validateFieldsNatively"],"mappings":"+EAKA,IAAMA,EAAc,SAAdA,EACJC,EACAC,EACAC,GAEA,YAHAD,IAAAA,IAAAA,EAA4B,CAAE,QAC1B,IAAJC,IAAAA,EAAO,IAEAC,OAAOC,KAAKJ,GAAQK,OAAO,SAACC,EAAKC,GACtC,IAAMC,EAAQN,EAAUA,EAAI,IAAIK,EAAQA,EAClCE,EAAQT,EAAOO,GAUrB,MARqB,iBAAVE,EACTH,EAAIE,GAAS,CACXE,QAASD,GAGXV,EAAYU,EAAOH,EAAKE,GAGnBF,CACT,EAAGL,EACL,EAEaU,EACX,SACEC,EACAC,GAEC,YAFY,IAAbA,IAAAA,EAAgB,CACdC,YAAY,aAGfC,EAAQC,EAASC,GAChB,IAAMC,EAASN,EAAOO,SAASJ,EAAQC,EAASH,GAIhD,OAAIK,EACK,CAAEH,OAAQ,CAAE,EAAEf,OAAQoB,EAAarB,EAAYmB,GAASD,KAGjEA,EAAQI,2BAA6BC,EAAuB,CAAE,EAAEL,GAEzD,CAAEF,OAAAA,EAAQf,OAAQ,IAC3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"nope.umd.js","sources":["../src/nope.ts"],"sourcesContent":["import type { FieldError, FieldErrors } from 'react-hook-form';\nimport { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport type { ShapeErrors } from 'nope-validator/lib/cjs/types';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ShapeErrors,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return Object.keys(errors).reduce((acc, key) => {\n const _path = path ? `${path}.${key}` : key;\n const error = errors[key];\n\n if (typeof error === 'string') {\n acc[_path] = {\n message: error,\n } as FieldError;\n } else {\n parseErrors(error, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const nopeResolver: Resolver =\n (\n schema,\n schemaOptions = {\n abortEarly: false,\n },\n ) =>\n (values, context, options) => {\n const result = schema.validate(values, context, schemaOptions) as\n | ShapeErrors\n | undefined;\n\n if (result) {\n return { values: {}, errors: toNestErrors(parseErrors(result), options) };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrors","errors","parsedErrors","path","Object","keys","reduce","acc","key","_path","error","message","schema","schemaOptions","abortEarly","values","context","options","result","validate","toNestErrors","shouldUseNativeValidation","validateFieldsNatively"],"mappings":"0TAKA,IAAMA,EAAc,SAAdA,EACJC,EACAC,EACAC,GAEA,YAHAD,IAAAA,IAAAA,EAA4B,CAAE,QAC1B,IAAJC,IAAAA,EAAO,IAEAC,OAAOC,KAAKJ,GAAQK,OAAO,SAACC,EAAKC,GACtC,IAAMC,EAAQN,EAAUA,EAAI,IAAIK,EAAQA,EAClCE,EAAQT,EAAOO,GAUrB,MARqB,iBAAVE,EACTH,EAAIE,GAAS,CACXE,QAASD,GAGXV,EAAYU,EAAOH,EAAKE,GAGnBF,CACT,EAAGL,EACL,iBAGE,SACEU,EACAC,GAEC,YAFY,IAAbA,IAAAA,EAAgB,CACdC,YAAY,aAGfC,EAAQC,EAASC,GAChB,IAAMC,EAASN,EAAOO,SAASJ,EAAQC,EAASH,GAIhD,OAAIK,EACK,CAAEH,OAAQ,CAAE,EAAEd,OAAQmB,EAAAA,aAAapB,EAAYkB,GAASD,KAGjEA,EAAQI,2BAA6BC,EAAsBA,uBAAC,CAAE,EAAEL,GAEzD,CAAEF,OAAAA,EAAQd,OAAQ,IAC3B,CAAC"}
1
+ {"version":3,"file":"nope.umd.js","sources":["../src/nope.ts"],"sourcesContent":["import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';\nimport type { ShapeErrors } from 'nope-validator/lib/cjs/types';\nimport type { FieldError, FieldErrors } from 'react-hook-form';\nimport type { Resolver } from './types';\n\nconst parseErrors = (\n errors: ShapeErrors,\n parsedErrors: FieldErrors = {},\n path = '',\n) => {\n return Object.keys(errors).reduce((acc, key) => {\n const _path = path ? `${path}.${key}` : key;\n const error = errors[key];\n\n if (typeof error === 'string') {\n acc[_path] = {\n message: error,\n } as FieldError;\n } else {\n parseErrors(error, acc, _path);\n }\n\n return acc;\n }, parsedErrors);\n};\n\nexport const nopeResolver: Resolver =\n (\n schema,\n schemaOptions = {\n abortEarly: false,\n },\n ) =>\n (values, context, options) => {\n const result = schema.validate(values, context, schemaOptions) as\n | ShapeErrors\n | undefined;\n\n if (result) {\n return { values: {}, errors: toNestErrors(parseErrors(result), options) };\n }\n\n options.shouldUseNativeValidation && validateFieldsNatively({}, options);\n\n return { values, errors: {} };\n };\n"],"names":["parseErrors","errors","parsedErrors","path","Object","keys","reduce","acc","key","_path","error","message","schema","schemaOptions","abortEarly","values","context","options","result","validate","toNestErrors","shouldUseNativeValidation","validateFieldsNatively"],"mappings":"0TAKA,IAAMA,EAAc,SAAdA,EACJC,EACAC,EACAC,GAEA,YAHAD,IAAAA,IAAAA,EAA4B,CAAE,QAC1B,IAAJC,IAAAA,EAAO,IAEAC,OAAOC,KAAKJ,GAAQK,OAAO,SAACC,EAAKC,GACtC,IAAMC,EAAQN,EAAUA,EAAI,IAAIK,EAAQA,EAClCE,EAAQT,EAAOO,GAUrB,MARqB,iBAAVE,EACTH,EAAIE,GAAS,CACXE,QAASD,GAGXV,EAAYU,EAAOH,EAAKE,GAGnBF,CACT,EAAGL,EACL,iBAGE,SACEU,EACAC,GAEC,YAFY,IAAbA,IAAAA,EAAgB,CACdC,YAAY,aAGfC,EAAQC,EAASC,GAChB,IAAMC,EAASN,EAAOO,SAASJ,EAAQC,EAASH,GAIhD,OAAIK,EACK,CAAEH,OAAQ,CAAE,EAAEd,OAAQmB,EAAAA,aAAapB,EAAYkB,GAASD,KAGjEA,EAAQI,2BAA6BC,EAAsBA,uBAAC,CAAE,EAAEL,GAEzD,CAAEF,OAAAA,EAAQd,OAAQ,IAC3B,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
2
1
  import type { NopeObject } from 'nope-validator/lib/cjs/NopeObject';
2
+ import type { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
3
3
  type ValidateOptions = Parameters<NopeObject['validate']>[2];
4
4
  type Context = Parameters<NopeObject['validate']>[1];
5
5
  export type Resolver = <T extends NopeObject>(schema: T, schemaOptions?: ValidateOptions, resolverOptions?: {
@@ -1,8 +1,8 @@
1
- import React from 'react';
2
1
  import { render, screen } from '@testing-library/react';
3
2
  import user from '@testing-library/user-event';
4
- import { useForm } from 'react-hook-form';
5
3
  import Nope from 'nope-validator';
4
+ import React from 'react';
5
+ import { useForm } from 'react-hook-form';
6
6
  import { nopeResolver } from '..';
7
7
 
8
8
  const USERNAME_REQUIRED_MESSAGE = 'username field is required';
@@ -1,8 +1,8 @@
1
- import React from 'react';
2
1
  import { render, screen } from '@testing-library/react';
3
2
  import user from '@testing-library/user-event';
4
- import { useForm } from 'react-hook-form';
5
3
  import Nope from 'nope-validator';
4
+ import React from 'react';
5
+ import { useForm } from 'react-hook-form';
6
6
  import { nopeResolver } from '..';
7
7
 
8
8
  const schema = Nope.object().shape({
@@ -1,5 +1,5 @@
1
- import { Field, InternalFieldName } from 'react-hook-form';
2
1
  import Nope from 'nope-validator';
2
+ import { Field, InternalFieldName } from 'react-hook-form';
3
3
 
4
4
  export const schema = Nope.object().shape({
5
5
  username: Nope.string().regex(/^\w+$/).min(2).max(30).required(),
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-console, @typescript-eslint/ban-ts-comment */
2
2
  import { nopeResolver } from '..';
3
- import { schema, validData, fields, invalidData } from './__fixtures__/data';
3
+ import { fields, invalidData, schema, validData } from './__fixtures__/data';
4
4
 
5
5
  const shouldUseNativeValidation = false;
6
6
 
package/nope/src/nope.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { FieldError, FieldErrors } from 'react-hook-form';
2
1
  import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';
3
2
  import type { ShapeErrors } from 'nope-validator/lib/cjs/types';
3
+ import type { FieldError, FieldErrors } from 'react-hook-form';
4
4
  import type { Resolver } from './types';
5
5
 
6
6
  const parseErrors = (
package/nope/src/types.ts CHANGED
@@ -1,9 +1,9 @@
1
+ import type { NopeObject } from 'nope-validator/lib/cjs/NopeObject';
1
2
  import type {
2
3
  FieldValues,
3
4
  ResolverOptions,
4
5
  ResolverResult,
5
6
  } from 'react-hook-form';
6
- import type { NopeObject } from 'nope-validator/lib/cjs/NopeObject';
7
7
 
8
8
  type ValidateOptions = Parameters<NopeObject['validate']>[2];
9
9
  type Context = Parameters<NopeObject['validate']>[1];
@@ -11,7 +11,7 @@ type Context = Parameters<NopeObject['validate']>[1];
11
11
  export type Resolver = <T extends NopeObject>(
12
12
  schema: T,
13
13
  schemaOptions?: ValidateOptions,
14
- resolverOptions?: { mode?: 'async' | 'sync', rawValues?: boolean; },
14
+ resolverOptions?: { mode?: 'async' | 'sync'; rawValues?: boolean },
15
15
  ) => <TFieldValues extends FieldValues, TContext extends Context>(
16
16
  values: TFieldValues,
17
17
  context: TContext | undefined,