@tanstack/form-core 0.42.0 → 0.43.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/dist/cjs/FieldApi.cjs +17 -28
- package/dist/cjs/FieldApi.cjs.map +1 -1
- package/dist/cjs/FieldApi.d.cts +91 -79
- package/dist/cjs/FormApi.cjs +50 -53
- package/dist/cjs/FormApi.cjs.map +1 -1
- package/dist/cjs/FormApi.d.cts +74 -67
- package/dist/cjs/formOptions.cjs.map +1 -1
- package/dist/cjs/formOptions.d.cts +2 -3
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/mergeForm.cjs +33 -9
- package/dist/cjs/mergeForm.cjs.map +1 -1
- package/dist/cjs/mergeForm.d.cts +2 -3
- package/dist/cjs/metaHelper.cjs.map +1 -1
- package/dist/cjs/metaHelper.d.cts +2 -3
- package/dist/cjs/standardSchemaValidator.cjs +24 -31
- package/dist/cjs/standardSchemaValidator.cjs.map +1 -1
- package/dist/cjs/standardSchemaValidator.d.cts +24 -4
- package/dist/cjs/types.d.cts +15 -27
- package/dist/cjs/util-types.d.cts +1 -0
- package/dist/cjs/utils.cjs +4 -0
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +4 -3
- package/dist/esm/FieldApi.d.ts +91 -79
- package/dist/esm/FieldApi.js +18 -29
- package/dist/esm/FieldApi.js.map +1 -1
- package/dist/esm/FormApi.d.ts +74 -67
- package/dist/esm/FormApi.js +52 -55
- package/dist/esm/FormApi.js.map +1 -1
- package/dist/esm/formOptions.d.ts +2 -3
- package/dist/esm/formOptions.js.map +1 -1
- package/dist/esm/index.js +4 -3
- package/dist/esm/mergeForm.d.ts +2 -3
- package/dist/esm/mergeForm.js +33 -9
- package/dist/esm/mergeForm.js.map +1 -1
- package/dist/esm/metaHelper.d.ts +2 -3
- package/dist/esm/metaHelper.js.map +1 -1
- package/dist/esm/standardSchemaValidator.d.ts +24 -4
- package/dist/esm/standardSchemaValidator.js +24 -31
- package/dist/esm/standardSchemaValidator.js.map +1 -1
- package/dist/esm/types.d.ts +15 -27
- package/dist/esm/util-types.d.ts +1 -0
- package/dist/esm/utils.d.ts +4 -3
- package/dist/esm/utils.js +4 -0
- package/dist/esm/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/FieldApi.ts +803 -273
- package/src/FormApi.ts +613 -183
- package/src/formOptions.ts +26 -4
- package/src/mergeForm.ts +63 -26
- package/src/metaHelper.ts +28 -6
- package/src/standardSchemaValidator.ts +47 -58
- package/src/types.ts +39 -34
- package/src/util-types.ts +2 -0
- package/src/utils.ts +15 -9
package/src/FieldApi.ts
CHANGED
|
@@ -1,39 +1,104 @@
|
|
|
1
1
|
import { Derived, batch } from '@tanstack/store'
|
|
2
2
|
import {
|
|
3
3
|
isStandardSchemaValidator,
|
|
4
|
-
|
|
4
|
+
standardSchemaValidators,
|
|
5
5
|
} from './standardSchemaValidator'
|
|
6
6
|
import { getAsyncValidatorArray, getBy, getSyncValidatorArray } from './utils'
|
|
7
|
-
import type {
|
|
8
|
-
|
|
7
|
+
import type {
|
|
8
|
+
DeepKeys,
|
|
9
|
+
DeepValue,
|
|
10
|
+
NoInfer,
|
|
11
|
+
UnwrapOneLevelOfArray,
|
|
12
|
+
} from './util-types'
|
|
13
|
+
import type {
|
|
14
|
+
StandardSchemaV1,
|
|
15
|
+
StandardSchemaV1Issue,
|
|
16
|
+
TStandardSchemaValidatorValue,
|
|
17
|
+
} from './standardSchemaValidator'
|
|
18
|
+
import type {
|
|
19
|
+
FieldInfo,
|
|
20
|
+
FormApi,
|
|
21
|
+
FormAsyncValidateOrFn,
|
|
22
|
+
FormValidateOrFn,
|
|
23
|
+
UnwrapFormAsyncValidateOrFn,
|
|
24
|
+
UnwrapFormValidateOrFn,
|
|
25
|
+
} from './FormApi'
|
|
9
26
|
import type {
|
|
10
27
|
UpdateMetaOptions,
|
|
11
28
|
ValidationCause,
|
|
12
29
|
ValidationError,
|
|
13
30
|
ValidationErrorMap,
|
|
14
|
-
ValidationSource,
|
|
15
|
-
Validator,
|
|
16
31
|
} from './types'
|
|
17
|
-
import type { DeepKeys, DeepValue, NoInfer } from './util-types'
|
|
18
32
|
import type { AsyncValidator, SyncValidator, Updater } from './utils'
|
|
19
33
|
|
|
34
|
+
/**
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
// TODO: Add the `Unwrap` type to the errors
|
|
38
|
+
type FieldErrorMapFromValidator<
|
|
39
|
+
TFormData,
|
|
40
|
+
TName extends DeepKeys<TFormData>,
|
|
41
|
+
TData extends DeepValue<TFormData, TName>,
|
|
42
|
+
TOnMount extends undefined | FieldValidateOrFn<TFormData, TName, TData>,
|
|
43
|
+
TOnChange extends undefined | FieldValidateOrFn<TFormData, TName, TData>,
|
|
44
|
+
TOnChangeAsync extends
|
|
45
|
+
| undefined
|
|
46
|
+
| FieldAsyncValidateOrFn<TFormData, TName, TData>,
|
|
47
|
+
TOnBlur extends undefined | FieldValidateOrFn<TFormData, TName, TData>,
|
|
48
|
+
TOnBlurAsync extends
|
|
49
|
+
| undefined
|
|
50
|
+
| FieldAsyncValidateOrFn<TFormData, TName, TData>,
|
|
51
|
+
TOnSubmit extends undefined | FieldValidateOrFn<TFormData, TName, TData>,
|
|
52
|
+
TOnSubmitAsync extends
|
|
53
|
+
| undefined
|
|
54
|
+
| FieldAsyncValidateOrFn<TFormData, TName, TData>,
|
|
55
|
+
> = Partial<
|
|
56
|
+
Record<
|
|
57
|
+
DeepKeys<TFormData>,
|
|
58
|
+
ValidationErrorMap<
|
|
59
|
+
TOnMount,
|
|
60
|
+
TOnChange,
|
|
61
|
+
TOnChangeAsync,
|
|
62
|
+
TOnBlur,
|
|
63
|
+
TOnBlurAsync,
|
|
64
|
+
TOnSubmit,
|
|
65
|
+
TOnSubmitAsync
|
|
66
|
+
>
|
|
67
|
+
>
|
|
68
|
+
>
|
|
69
|
+
|
|
20
70
|
/**
|
|
21
71
|
* @private
|
|
22
72
|
*/
|
|
23
73
|
export type FieldValidateFn<
|
|
24
74
|
TParentData,
|
|
25
75
|
TName extends DeepKeys<TParentData>,
|
|
26
|
-
TFieldValidator extends
|
|
27
|
-
| Validator<DeepValue<TParentData, TName>, unknown>
|
|
28
|
-
| undefined = undefined,
|
|
29
|
-
TFormValidator extends
|
|
30
|
-
| Validator<TParentData, unknown>
|
|
31
|
-
| undefined = undefined,
|
|
32
76
|
TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,
|
|
33
77
|
> = (props: {
|
|
34
78
|
value: TData
|
|
35
|
-
fieldApi: FieldApi<
|
|
36
|
-
|
|
79
|
+
fieldApi: FieldApi<
|
|
80
|
+
TParentData,
|
|
81
|
+
TName,
|
|
82
|
+
TData,
|
|
83
|
+
// This is technically an edge-type; which we try to keep non-`any`, but in this case
|
|
84
|
+
// It's referring to an inaccessible type from the field validate function inner types, so it's not a big deal
|
|
85
|
+
any,
|
|
86
|
+
any,
|
|
87
|
+
any,
|
|
88
|
+
any,
|
|
89
|
+
any,
|
|
90
|
+
any,
|
|
91
|
+
any,
|
|
92
|
+
any,
|
|
93
|
+
any,
|
|
94
|
+
any,
|
|
95
|
+
any,
|
|
96
|
+
any,
|
|
97
|
+
any,
|
|
98
|
+
any,
|
|
99
|
+
any
|
|
100
|
+
>
|
|
101
|
+
}) => unknown
|
|
37
102
|
|
|
38
103
|
/**
|
|
39
104
|
* @private
|
|
@@ -41,37 +106,69 @@ export type FieldValidateFn<
|
|
|
41
106
|
export type FieldValidateOrFn<
|
|
42
107
|
TParentData,
|
|
43
108
|
TName extends DeepKeys<TParentData>,
|
|
44
|
-
TFieldValidator extends
|
|
45
|
-
| Validator<DeepValue<TParentData, TName>, unknown>
|
|
46
|
-
| undefined = undefined,
|
|
47
|
-
TFormValidator extends
|
|
48
|
-
| Validator<TParentData, unknown>
|
|
49
|
-
| undefined = undefined,
|
|
50
109
|
TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,
|
|
51
110
|
> =
|
|
52
|
-
|
|
|
53
|
-
| (TFormValidator extends Validator<TParentData, infer FFN> ? FFN : never)
|
|
54
|
-
| FieldValidateFn<TParentData, TName, TFieldValidator, TFormValidator, TData>
|
|
111
|
+
| FieldValidateFn<TParentData, TName, TData>
|
|
55
112
|
| StandardSchemaV1<TData, unknown>
|
|
56
113
|
|
|
114
|
+
export type UnwrapFieldValidateOrFn<
|
|
115
|
+
TParentData,
|
|
116
|
+
TName extends DeepKeys<TParentData>,
|
|
117
|
+
TValidateOrFn extends undefined | FieldValidateOrFn<any, any, any>,
|
|
118
|
+
TFormValidateOrFn extends undefined | FormValidateOrFn<any>,
|
|
119
|
+
> =
|
|
120
|
+
| ([TFormValidateOrFn] extends [StandardSchemaV1<any, infer TStandardOut>]
|
|
121
|
+
? TName extends keyof TStandardOut
|
|
122
|
+
? StandardSchemaV1Issue[]
|
|
123
|
+
: undefined
|
|
124
|
+
: undefined)
|
|
125
|
+
| (UnwrapFormValidateOrFn<TFormValidateOrFn> extends infer TFormValidateVal
|
|
126
|
+
? TFormValidateVal extends { fields: any }
|
|
127
|
+
? TName extends keyof TFormValidateVal['fields']
|
|
128
|
+
? TFormValidateVal['fields'][TName]
|
|
129
|
+
: undefined
|
|
130
|
+
: undefined
|
|
131
|
+
: never)
|
|
132
|
+
| ([TValidateOrFn] extends [FieldValidateFn<any, any, any>]
|
|
133
|
+
? ReturnType<TValidateOrFn>
|
|
134
|
+
: [TValidateOrFn] extends [StandardSchemaV1<any, any>]
|
|
135
|
+
? // TODO: Check if `disableErrorFlat` is enabled, if so, return StandardSchemaV1Issue[][]
|
|
136
|
+
StandardSchemaV1Issue[]
|
|
137
|
+
: undefined)
|
|
138
|
+
|
|
57
139
|
/**
|
|
58
140
|
* @private
|
|
59
141
|
*/
|
|
60
142
|
export type FieldValidateAsyncFn<
|
|
61
143
|
TParentData,
|
|
62
144
|
TName extends DeepKeys<TParentData>,
|
|
63
|
-
TFieldValidator extends
|
|
64
|
-
| Validator<DeepValue<TParentData, TName>, unknown>
|
|
65
|
-
| undefined = undefined,
|
|
66
|
-
TFormValidator extends
|
|
67
|
-
| Validator<TParentData, unknown>
|
|
68
|
-
| undefined = undefined,
|
|
69
145
|
TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,
|
|
70
146
|
> = (options: {
|
|
71
147
|
value: TData
|
|
72
|
-
fieldApi: FieldApi<
|
|
148
|
+
fieldApi: FieldApi<
|
|
149
|
+
TParentData,
|
|
150
|
+
TName,
|
|
151
|
+
TData,
|
|
152
|
+
// This is technically an edge-type; which we try to keep non-`any`, but in this case
|
|
153
|
+
// It's referring to an inaccessible type from the field validate function inner types, so it's not a big deal
|
|
154
|
+
any,
|
|
155
|
+
any,
|
|
156
|
+
any,
|
|
157
|
+
any,
|
|
158
|
+
any,
|
|
159
|
+
any,
|
|
160
|
+
any,
|
|
161
|
+
any,
|
|
162
|
+
any,
|
|
163
|
+
any,
|
|
164
|
+
any,
|
|
165
|
+
any,
|
|
166
|
+
any,
|
|
167
|
+
any,
|
|
168
|
+
any
|
|
169
|
+
>
|
|
73
170
|
signal: AbortSignal
|
|
74
|
-
}) =>
|
|
171
|
+
}) => unknown | Promise<unknown>
|
|
75
172
|
|
|
76
173
|
/**
|
|
77
174
|
* @private
|
|
@@ -79,90 +176,103 @@ export type FieldValidateAsyncFn<
|
|
|
79
176
|
export type FieldAsyncValidateOrFn<
|
|
80
177
|
TParentData,
|
|
81
178
|
TName extends DeepKeys<TParentData>,
|
|
82
|
-
TFieldValidator extends
|
|
83
|
-
| Validator<DeepValue<TParentData, TName>, unknown>
|
|
84
|
-
| undefined = undefined,
|
|
85
|
-
TFormValidator extends
|
|
86
|
-
| Validator<TParentData, unknown>
|
|
87
|
-
| undefined = undefined,
|
|
88
179
|
TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,
|
|
89
180
|
> =
|
|
90
|
-
|
|
|
91
|
-
| (TFormValidator extends Validator<TParentData, infer FFN> ? FFN : never)
|
|
92
|
-
| FieldValidateAsyncFn<
|
|
93
|
-
TParentData,
|
|
94
|
-
TName,
|
|
95
|
-
TFieldValidator,
|
|
96
|
-
TFormValidator,
|
|
97
|
-
TData
|
|
98
|
-
>
|
|
181
|
+
| FieldValidateAsyncFn<TParentData, TName, TData>
|
|
99
182
|
| StandardSchemaV1<TData, unknown>
|
|
100
183
|
|
|
184
|
+
export type UnwrapFieldAsyncValidateOrFn<
|
|
185
|
+
TParentData,
|
|
186
|
+
TName extends DeepKeys<TParentData>,
|
|
187
|
+
TValidateOrFn extends undefined | FieldAsyncValidateOrFn<any, any, any>,
|
|
188
|
+
TFormValidateOrFn extends undefined | FormAsyncValidateOrFn<any>,
|
|
189
|
+
> =
|
|
190
|
+
| ([TFormValidateOrFn] extends [StandardSchemaV1<any, infer TStandardOut>]
|
|
191
|
+
? TName extends keyof TStandardOut
|
|
192
|
+
? StandardSchemaV1Issue[]
|
|
193
|
+
: undefined
|
|
194
|
+
: undefined)
|
|
195
|
+
| (UnwrapFormAsyncValidateOrFn<TFormValidateOrFn> extends infer TFormValidateVal
|
|
196
|
+
? TFormValidateVal extends { fields: any }
|
|
197
|
+
? TName extends keyof TFormValidateVal['fields']
|
|
198
|
+
? TFormValidateVal['fields'][TName]
|
|
199
|
+
: undefined
|
|
200
|
+
: undefined
|
|
201
|
+
: never)
|
|
202
|
+
| ([TValidateOrFn] extends [FieldValidateAsyncFn<any, any, any>]
|
|
203
|
+
? Awaited<ReturnType<TValidateOrFn>>
|
|
204
|
+
: [TValidateOrFn] extends [StandardSchemaV1<any, any>]
|
|
205
|
+
? // TODO: Check if `disableErrorFlat` is enabled, if so, return StandardSchemaV1Issue[][]
|
|
206
|
+
StandardSchemaV1Issue[]
|
|
207
|
+
: undefined)
|
|
208
|
+
|
|
101
209
|
/**
|
|
102
210
|
* @private
|
|
103
211
|
*/
|
|
104
212
|
export type FieldListenerFn<
|
|
105
213
|
TParentData,
|
|
106
214
|
TName extends DeepKeys<TParentData>,
|
|
107
|
-
TFieldValidator extends
|
|
108
|
-
| Validator<DeepValue<TParentData, TName>, unknown>
|
|
109
|
-
| undefined = undefined,
|
|
110
|
-
TFormValidator extends
|
|
111
|
-
| Validator<TParentData, unknown>
|
|
112
|
-
| undefined = undefined,
|
|
113
215
|
TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,
|
|
114
216
|
> = (props: {
|
|
115
217
|
value: TData
|
|
116
|
-
fieldApi: FieldApi<
|
|
218
|
+
fieldApi: FieldApi<
|
|
219
|
+
TParentData,
|
|
220
|
+
TName,
|
|
221
|
+
TData,
|
|
222
|
+
// This is technically an edge-type; which we try to keep non-`any`, but in this case
|
|
223
|
+
// It's referring to an inaccessible type from the field listener function inner types, so it's not a big deal
|
|
224
|
+
any,
|
|
225
|
+
any,
|
|
226
|
+
any,
|
|
227
|
+
any,
|
|
228
|
+
any,
|
|
229
|
+
any,
|
|
230
|
+
any,
|
|
231
|
+
any,
|
|
232
|
+
any,
|
|
233
|
+
any,
|
|
234
|
+
any,
|
|
235
|
+
any,
|
|
236
|
+
any,
|
|
237
|
+
any,
|
|
238
|
+
any
|
|
239
|
+
>
|
|
117
240
|
}) => void
|
|
118
241
|
|
|
119
242
|
export interface FieldValidators<
|
|
120
243
|
TParentData,
|
|
121
244
|
TName extends DeepKeys<TParentData>,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
245
|
+
TData extends DeepValue<TParentData, TName>,
|
|
246
|
+
TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
247
|
+
TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
248
|
+
TOnChangeAsync extends
|
|
249
|
+
| undefined
|
|
250
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
251
|
+
TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
252
|
+
TOnBlurAsync extends
|
|
253
|
+
| undefined
|
|
254
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
255
|
+
TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
256
|
+
TOnSubmitAsync extends
|
|
257
|
+
| undefined
|
|
258
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
129
259
|
> {
|
|
130
260
|
/**
|
|
131
|
-
* An optional function that
|
|
261
|
+
* An optional function, that runs on the mount event of input.
|
|
132
262
|
*/
|
|
133
|
-
onMount?:
|
|
134
|
-
TParentData,
|
|
135
|
-
TName,
|
|
136
|
-
TFieldValidator,
|
|
137
|
-
TFormValidator,
|
|
138
|
-
TData
|
|
139
|
-
>
|
|
263
|
+
onMount?: TOnMount
|
|
140
264
|
/**
|
|
141
|
-
* An optional
|
|
142
|
-
* If `validatorAdapter` is passed, this may also accept a property from the respective adapter
|
|
265
|
+
* An optional function, that runs on the change event of input.
|
|
143
266
|
*
|
|
144
|
-
* @example z.string().min(1)
|
|
267
|
+
* @example z.string().min(1)
|
|
145
268
|
*/
|
|
146
|
-
onChange?:
|
|
147
|
-
TParentData,
|
|
148
|
-
TName,
|
|
149
|
-
TFieldValidator,
|
|
150
|
-
TFormValidator,
|
|
151
|
-
TData
|
|
152
|
-
>
|
|
269
|
+
onChange?: TOnChange
|
|
153
270
|
/**
|
|
154
|
-
* An optional property similar to `onChange` but async validation
|
|
155
|
-
* is passed, this may also accept a property from the respective adapter
|
|
271
|
+
* An optional property similar to `onChange` but async validation
|
|
156
272
|
*
|
|
157
|
-
* @example z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })
|
|
273
|
+
* @example z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })
|
|
158
274
|
*/
|
|
159
|
-
onChangeAsync?:
|
|
160
|
-
TParentData,
|
|
161
|
-
TName,
|
|
162
|
-
TFieldValidator,
|
|
163
|
-
TFormValidator,
|
|
164
|
-
TData
|
|
165
|
-
>
|
|
275
|
+
onChangeAsync?: TOnChangeAsync
|
|
166
276
|
/**
|
|
167
277
|
* An optional number to represent how long the `onChangeAsync` should wait before running
|
|
168
278
|
*
|
|
@@ -175,30 +285,16 @@ export interface FieldValidators<
|
|
|
175
285
|
onChangeListenTo?: DeepKeys<TParentData>[]
|
|
176
286
|
/**
|
|
177
287
|
* An optional function, that runs on the blur event of input.
|
|
178
|
-
* If `validatorAdapter` is passed, this may also accept a property from the respective adapter
|
|
179
288
|
*
|
|
180
|
-
* @example z.string().min(1)
|
|
289
|
+
* @example z.string().min(1)
|
|
181
290
|
*/
|
|
182
|
-
onBlur?:
|
|
183
|
-
TParentData,
|
|
184
|
-
TName,
|
|
185
|
-
TFieldValidator,
|
|
186
|
-
TFormValidator,
|
|
187
|
-
TData
|
|
188
|
-
>
|
|
291
|
+
onBlur?: TOnBlur
|
|
189
292
|
/**
|
|
190
|
-
* An optional property similar to `onBlur` but async validation.
|
|
191
|
-
* is passed, this may also accept a property from the respective adapter
|
|
293
|
+
* An optional property similar to `onBlur` but async validation.
|
|
192
294
|
*
|
|
193
|
-
* @example z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })
|
|
295
|
+
* @example z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })
|
|
194
296
|
*/
|
|
195
|
-
onBlurAsync?:
|
|
196
|
-
TParentData,
|
|
197
|
-
TName,
|
|
198
|
-
TFieldValidator,
|
|
199
|
-
TFormValidator,
|
|
200
|
-
TData
|
|
201
|
-
>
|
|
297
|
+
onBlurAsync?: TOnBlurAsync
|
|
202
298
|
|
|
203
299
|
/**
|
|
204
300
|
* An optional number to represent how long the `onBlurAsync` should wait before running
|
|
@@ -212,71 +308,27 @@ export interface FieldValidators<
|
|
|
212
308
|
onBlurListenTo?: DeepKeys<TParentData>[]
|
|
213
309
|
/**
|
|
214
310
|
* An optional function, that runs on the submit event of form.
|
|
215
|
-
* If `validatorAdapter` is passed, this may also accept a property from the respective adapter
|
|
216
311
|
*
|
|
217
|
-
* @example z.string().min(1)
|
|
312
|
+
* @example z.string().min(1)
|
|
218
313
|
*/
|
|
219
|
-
onSubmit?:
|
|
220
|
-
TParentData,
|
|
221
|
-
TName,
|
|
222
|
-
TFieldValidator,
|
|
223
|
-
TFormValidator,
|
|
224
|
-
TData
|
|
225
|
-
>
|
|
314
|
+
onSubmit?: TOnSubmit
|
|
226
315
|
/**
|
|
227
|
-
* An optional property similar to `onSubmit` but async validation.
|
|
228
|
-
* is passed, this may also accept a property from the respective adapter
|
|
316
|
+
* An optional property similar to `onSubmit` but async validation.
|
|
229
317
|
*
|
|
230
|
-
* @example z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })
|
|
318
|
+
* @example z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })
|
|
231
319
|
*/
|
|
232
|
-
onSubmitAsync?:
|
|
233
|
-
TParentData,
|
|
234
|
-
TName,
|
|
235
|
-
TFieldValidator,
|
|
236
|
-
TFormValidator,
|
|
237
|
-
TData
|
|
238
|
-
>
|
|
320
|
+
onSubmitAsync?: TOnSubmitAsync
|
|
239
321
|
}
|
|
240
322
|
|
|
241
323
|
export interface FieldListeners<
|
|
242
324
|
TParentData,
|
|
243
325
|
TName extends DeepKeys<TParentData>,
|
|
244
|
-
TFieldValidator extends
|
|
245
|
-
| Validator<DeepValue<TParentData, TName>, unknown>
|
|
246
|
-
| undefined = undefined,
|
|
247
|
-
TFormValidator extends
|
|
248
|
-
| Validator<TParentData, unknown>
|
|
249
|
-
| undefined = undefined,
|
|
250
326
|
TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>,
|
|
251
327
|
> {
|
|
252
|
-
onChange?: FieldListenerFn<
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
TFormValidator,
|
|
257
|
-
TData
|
|
258
|
-
>
|
|
259
|
-
onBlur?: FieldListenerFn<
|
|
260
|
-
TParentData,
|
|
261
|
-
TName,
|
|
262
|
-
TFieldValidator,
|
|
263
|
-
TFormValidator,
|
|
264
|
-
TData
|
|
265
|
-
>
|
|
266
|
-
onMount?: FieldListenerFn<
|
|
267
|
-
TParentData,
|
|
268
|
-
TName,
|
|
269
|
-
TFieldValidator,
|
|
270
|
-
TFormValidator,
|
|
271
|
-
TData
|
|
272
|
-
>
|
|
273
|
-
onSubmit?: FieldListenerFn<
|
|
274
|
-
TParentData,
|
|
275
|
-
TName,
|
|
276
|
-
TFieldValidator,
|
|
277
|
-
TFormValidator,
|
|
278
|
-
TData
|
|
279
|
-
>
|
|
328
|
+
onChange?: FieldListenerFn<TParentData, TName, TData>
|
|
329
|
+
onBlur?: FieldListenerFn<TParentData, TName, TData>
|
|
330
|
+
onMount?: FieldListenerFn<TParentData, TName, TData>
|
|
331
|
+
onSubmit?: FieldListenerFn<TParentData, TName, TData>
|
|
280
332
|
}
|
|
281
333
|
|
|
282
334
|
/**
|
|
@@ -285,13 +337,20 @@ export interface FieldListeners<
|
|
|
285
337
|
export interface FieldOptions<
|
|
286
338
|
TParentData,
|
|
287
339
|
TName extends DeepKeys<TParentData>,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
|
293
|
-
|
|
|
294
|
-
|
|
340
|
+
TData extends DeepValue<TParentData, TName>,
|
|
341
|
+
TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
342
|
+
TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
343
|
+
TOnChangeAsync extends
|
|
344
|
+
| undefined
|
|
345
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
346
|
+
TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
347
|
+
TOnBlurAsync extends
|
|
348
|
+
| undefined
|
|
349
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
350
|
+
TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
351
|
+
TOnSubmitAsync extends
|
|
352
|
+
| undefined
|
|
353
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
295
354
|
> {
|
|
296
355
|
/**
|
|
297
356
|
* The field name. The type will be `DeepKeys<TParentData>` to ensure your name is a deep key of the parent dataset.
|
|
@@ -309,34 +368,53 @@ export interface FieldOptions<
|
|
|
309
368
|
* If `true`, always run async validation, even if there are errors emitted during synchronous validation.
|
|
310
369
|
*/
|
|
311
370
|
asyncAlways?: boolean
|
|
312
|
-
/**
|
|
313
|
-
* A validator provided by an extension, like `yupValidator` from `@tanstack/yup-form-adapter`
|
|
314
|
-
*/
|
|
315
|
-
validatorAdapter?: TFieldValidator
|
|
316
371
|
/**
|
|
317
372
|
* A list of validators to pass to the field
|
|
318
373
|
*/
|
|
319
374
|
validators?: FieldValidators<
|
|
320
375
|
TParentData,
|
|
321
376
|
TName,
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
377
|
+
TData,
|
|
378
|
+
TOnMount,
|
|
379
|
+
TOnChange,
|
|
380
|
+
TOnChangeAsync,
|
|
381
|
+
TOnBlur,
|
|
382
|
+
TOnBlurAsync,
|
|
383
|
+
TOnSubmit,
|
|
384
|
+
TOnSubmitAsync
|
|
325
385
|
>
|
|
326
386
|
/**
|
|
327
387
|
* An optional object with default metadata for the field.
|
|
328
388
|
*/
|
|
329
|
-
defaultMeta?: Partial<
|
|
389
|
+
defaultMeta?: Partial<
|
|
390
|
+
FieldMeta<
|
|
391
|
+
TParentData,
|
|
392
|
+
TName,
|
|
393
|
+
TData,
|
|
394
|
+
TOnMount,
|
|
395
|
+
TOnChange,
|
|
396
|
+
TOnChangeAsync,
|
|
397
|
+
TOnBlur,
|
|
398
|
+
TOnBlurAsync,
|
|
399
|
+
TOnSubmit,
|
|
400
|
+
TOnSubmitAsync,
|
|
401
|
+
any,
|
|
402
|
+
any,
|
|
403
|
+
any,
|
|
404
|
+
any,
|
|
405
|
+
any,
|
|
406
|
+
any,
|
|
407
|
+
any
|
|
408
|
+
>
|
|
409
|
+
>
|
|
330
410
|
/**
|
|
331
411
|
* A list of listeners which attach to the corresponding events
|
|
332
412
|
*/
|
|
333
|
-
listeners?: FieldListeners<
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
TData
|
|
339
|
-
>
|
|
413
|
+
listeners?: FieldListeners<TParentData, TName, TData>
|
|
414
|
+
/**
|
|
415
|
+
* Disable the `flat(1)` operation on `field.errors`. This is useful if you want to keep the error structure as is. Not suggested for most use-cases.
|
|
416
|
+
*/
|
|
417
|
+
disableErrorFlat?: boolean
|
|
340
418
|
}
|
|
341
419
|
|
|
342
420
|
/**
|
|
@@ -345,24 +423,78 @@ export interface FieldOptions<
|
|
|
345
423
|
export interface FieldApiOptions<
|
|
346
424
|
TParentData,
|
|
347
425
|
TName extends DeepKeys<TParentData>,
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
|
353
|
-
|
|
|
354
|
-
|
|
426
|
+
TData extends DeepValue<TParentData, TName>,
|
|
427
|
+
TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
428
|
+
TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
429
|
+
TOnChangeAsync extends
|
|
430
|
+
| undefined
|
|
431
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
432
|
+
TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
433
|
+
TOnBlurAsync extends
|
|
434
|
+
| undefined
|
|
435
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
436
|
+
TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
437
|
+
TOnSubmitAsync extends
|
|
438
|
+
| undefined
|
|
439
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
440
|
+
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
|
|
441
|
+
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
|
|
442
|
+
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
443
|
+
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
|
|
444
|
+
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
445
|
+
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
|
|
446
|
+
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
447
|
+
TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
355
448
|
> extends FieldOptions<
|
|
356
449
|
TParentData,
|
|
357
450
|
TName,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
451
|
+
TData,
|
|
452
|
+
TOnMount,
|
|
453
|
+
TOnChange,
|
|
454
|
+
TOnChangeAsync,
|
|
455
|
+
TOnBlur,
|
|
456
|
+
TOnBlurAsync,
|
|
457
|
+
TOnSubmit,
|
|
458
|
+
TOnSubmitAsync
|
|
361
459
|
> {
|
|
362
|
-
form: FormApi<
|
|
460
|
+
form: FormApi<
|
|
461
|
+
TParentData,
|
|
462
|
+
TFormOnMount,
|
|
463
|
+
TFormOnChange,
|
|
464
|
+
TFormOnChangeAsync,
|
|
465
|
+
TFormOnBlur,
|
|
466
|
+
TFormOnBlurAsync,
|
|
467
|
+
TFormOnSubmit,
|
|
468
|
+
TFormOnSubmitAsync,
|
|
469
|
+
TFormOnServer
|
|
470
|
+
>
|
|
363
471
|
}
|
|
364
472
|
|
|
365
|
-
export type FieldMetaBase
|
|
473
|
+
export type FieldMetaBase<
|
|
474
|
+
TParentData,
|
|
475
|
+
TName extends DeepKeys<TParentData>,
|
|
476
|
+
TData extends DeepValue<TParentData, TName>,
|
|
477
|
+
TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
478
|
+
TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
479
|
+
TOnChangeAsync extends
|
|
480
|
+
| undefined
|
|
481
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
482
|
+
TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
483
|
+
TOnBlurAsync extends
|
|
484
|
+
| undefined
|
|
485
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
486
|
+
TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
487
|
+
TOnSubmitAsync extends
|
|
488
|
+
| undefined
|
|
489
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
490
|
+
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
|
|
491
|
+
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
|
|
492
|
+
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
493
|
+
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
|
|
494
|
+
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
495
|
+
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
|
|
496
|
+
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
497
|
+
> = {
|
|
366
498
|
/**
|
|
367
499
|
* A flag indicating whether the field has been touched.
|
|
368
500
|
*/
|
|
@@ -378,33 +510,262 @@ export type FieldMetaBase = {
|
|
|
378
510
|
/**
|
|
379
511
|
* A map of errors related to the field value.
|
|
380
512
|
*/
|
|
381
|
-
errorMap: ValidationErrorMap
|
|
513
|
+
errorMap: ValidationErrorMap<
|
|
514
|
+
UnwrapFieldValidateOrFn<TParentData, TName, TOnMount, TFormOnMount>,
|
|
515
|
+
UnwrapFieldValidateOrFn<TParentData, TName, TOnChange, TFormOnChange>,
|
|
516
|
+
UnwrapFieldAsyncValidateOrFn<
|
|
517
|
+
TParentData,
|
|
518
|
+
TName,
|
|
519
|
+
TOnChangeAsync,
|
|
520
|
+
TFormOnChangeAsync
|
|
521
|
+
>,
|
|
522
|
+
UnwrapFieldValidateOrFn<TParentData, TName, TOnBlur, TFormOnBlur>,
|
|
523
|
+
UnwrapFieldAsyncValidateOrFn<
|
|
524
|
+
TParentData,
|
|
525
|
+
TName,
|
|
526
|
+
TOnBlurAsync,
|
|
527
|
+
TFormOnBlurAsync
|
|
528
|
+
>,
|
|
529
|
+
UnwrapFieldValidateOrFn<TParentData, TName, TOnSubmit, TFormOnSubmit>,
|
|
530
|
+
UnwrapFieldAsyncValidateOrFn<
|
|
531
|
+
TParentData,
|
|
532
|
+
TName,
|
|
533
|
+
TOnSubmitAsync,
|
|
534
|
+
TFormOnSubmitAsync
|
|
535
|
+
>
|
|
536
|
+
>
|
|
382
537
|
/**
|
|
383
538
|
* A flag indicating whether the field is currently being validated.
|
|
384
539
|
*/
|
|
385
540
|
isValidating: boolean
|
|
386
541
|
}
|
|
387
542
|
|
|
388
|
-
export type
|
|
543
|
+
export type AnyFieldMetaBase = FieldMetaBase<
|
|
544
|
+
any,
|
|
545
|
+
any,
|
|
546
|
+
any,
|
|
547
|
+
any,
|
|
548
|
+
any,
|
|
549
|
+
any,
|
|
550
|
+
any,
|
|
551
|
+
any,
|
|
552
|
+
any,
|
|
553
|
+
any,
|
|
554
|
+
any,
|
|
555
|
+
any,
|
|
556
|
+
any,
|
|
557
|
+
any,
|
|
558
|
+
any,
|
|
559
|
+
any,
|
|
560
|
+
any
|
|
561
|
+
>
|
|
562
|
+
|
|
563
|
+
export type FieldMetaDerived<
|
|
564
|
+
TParentData,
|
|
565
|
+
TName extends DeepKeys<TParentData>,
|
|
566
|
+
TData extends DeepValue<TParentData, TName>,
|
|
567
|
+
TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
568
|
+
TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
569
|
+
TOnChangeAsync extends
|
|
570
|
+
| undefined
|
|
571
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
572
|
+
TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
573
|
+
TOnBlurAsync extends
|
|
574
|
+
| undefined
|
|
575
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
576
|
+
TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
577
|
+
TOnSubmitAsync extends
|
|
578
|
+
| undefined
|
|
579
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
580
|
+
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
|
|
581
|
+
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
|
|
582
|
+
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
583
|
+
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
|
|
584
|
+
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
585
|
+
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
|
|
586
|
+
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
587
|
+
> = {
|
|
389
588
|
/**
|
|
390
589
|
* An array of errors related to the field value.
|
|
391
590
|
*/
|
|
392
|
-
errors:
|
|
591
|
+
errors: Array<
|
|
592
|
+
| UnwrapOneLevelOfArray<
|
|
593
|
+
UnwrapFieldValidateOrFn<TParentData, TName, TOnMount, TFormOnMount>
|
|
594
|
+
>
|
|
595
|
+
| UnwrapOneLevelOfArray<
|
|
596
|
+
UnwrapFieldValidateOrFn<TParentData, TName, TOnChange, TFormOnChange>
|
|
597
|
+
>
|
|
598
|
+
| UnwrapOneLevelOfArray<
|
|
599
|
+
UnwrapFieldAsyncValidateOrFn<
|
|
600
|
+
TParentData,
|
|
601
|
+
TName,
|
|
602
|
+
TOnChangeAsync,
|
|
603
|
+
TFormOnChangeAsync
|
|
604
|
+
>
|
|
605
|
+
>
|
|
606
|
+
| UnwrapOneLevelOfArray<
|
|
607
|
+
UnwrapFieldValidateOrFn<TParentData, TName, TOnBlur, TFormOnBlur>
|
|
608
|
+
>
|
|
609
|
+
| UnwrapOneLevelOfArray<
|
|
610
|
+
UnwrapFieldAsyncValidateOrFn<
|
|
611
|
+
TParentData,
|
|
612
|
+
TName,
|
|
613
|
+
TOnBlurAsync,
|
|
614
|
+
TFormOnBlurAsync
|
|
615
|
+
>
|
|
616
|
+
>
|
|
617
|
+
| UnwrapOneLevelOfArray<
|
|
618
|
+
UnwrapFieldValidateOrFn<TParentData, TName, TOnSubmit, TFormOnSubmit>
|
|
619
|
+
>
|
|
620
|
+
| UnwrapOneLevelOfArray<
|
|
621
|
+
UnwrapFieldAsyncValidateOrFn<
|
|
622
|
+
TParentData,
|
|
623
|
+
TName,
|
|
624
|
+
TOnSubmitAsync,
|
|
625
|
+
TFormOnSubmitAsync
|
|
626
|
+
>
|
|
627
|
+
>
|
|
628
|
+
>
|
|
393
629
|
/**
|
|
394
630
|
* A flag that is `true` if the field's value has not been modified by the user. Opposite of `isDirty`.
|
|
395
631
|
*/
|
|
396
632
|
isPristine: boolean
|
|
397
633
|
}
|
|
398
634
|
|
|
635
|
+
export type AnyFieldMetaDerived = FieldMetaDerived<
|
|
636
|
+
any,
|
|
637
|
+
any,
|
|
638
|
+
any,
|
|
639
|
+
any,
|
|
640
|
+
any,
|
|
641
|
+
any,
|
|
642
|
+
any,
|
|
643
|
+
any,
|
|
644
|
+
any,
|
|
645
|
+
any,
|
|
646
|
+
any,
|
|
647
|
+
any,
|
|
648
|
+
any,
|
|
649
|
+
any,
|
|
650
|
+
any,
|
|
651
|
+
any,
|
|
652
|
+
any
|
|
653
|
+
>
|
|
654
|
+
|
|
399
655
|
/**
|
|
400
656
|
* An object type representing the metadata of a field in a form.
|
|
401
657
|
*/
|
|
402
|
-
export type FieldMeta
|
|
658
|
+
export type FieldMeta<
|
|
659
|
+
TParentData,
|
|
660
|
+
TName extends DeepKeys<TParentData>,
|
|
661
|
+
TData extends DeepValue<TParentData, TName>,
|
|
662
|
+
TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
663
|
+
TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
664
|
+
TOnChangeAsync extends
|
|
665
|
+
| undefined
|
|
666
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
667
|
+
TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
668
|
+
TOnBlurAsync extends
|
|
669
|
+
| undefined
|
|
670
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
671
|
+
TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
672
|
+
TOnSubmitAsync extends
|
|
673
|
+
| undefined
|
|
674
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
675
|
+
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
|
|
676
|
+
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
|
|
677
|
+
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
678
|
+
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
|
|
679
|
+
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
680
|
+
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
|
|
681
|
+
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
682
|
+
> = FieldMetaBase<
|
|
683
|
+
TParentData,
|
|
684
|
+
TName,
|
|
685
|
+
TData,
|
|
686
|
+
TOnMount,
|
|
687
|
+
TOnChange,
|
|
688
|
+
TOnChangeAsync,
|
|
689
|
+
TOnBlur,
|
|
690
|
+
TOnBlurAsync,
|
|
691
|
+
TOnSubmit,
|
|
692
|
+
TOnSubmitAsync,
|
|
693
|
+
TFormOnMount,
|
|
694
|
+
TFormOnChange,
|
|
695
|
+
TFormOnChangeAsync,
|
|
696
|
+
TFormOnBlur,
|
|
697
|
+
TFormOnBlurAsync,
|
|
698
|
+
TFormOnSubmit,
|
|
699
|
+
TFormOnSubmitAsync
|
|
700
|
+
> &
|
|
701
|
+
FieldMetaDerived<
|
|
702
|
+
TParentData,
|
|
703
|
+
TName,
|
|
704
|
+
TData,
|
|
705
|
+
TOnMount,
|
|
706
|
+
TOnChange,
|
|
707
|
+
TOnChangeAsync,
|
|
708
|
+
TOnBlur,
|
|
709
|
+
TOnBlurAsync,
|
|
710
|
+
TOnSubmit,
|
|
711
|
+
TOnSubmitAsync,
|
|
712
|
+
TFormOnMount,
|
|
713
|
+
TFormOnChange,
|
|
714
|
+
TFormOnChangeAsync,
|
|
715
|
+
TFormOnBlur,
|
|
716
|
+
TFormOnBlurAsync,
|
|
717
|
+
TFormOnSubmit,
|
|
718
|
+
TFormOnSubmitAsync
|
|
719
|
+
>
|
|
720
|
+
|
|
721
|
+
export type AnyFieldMeta = FieldMeta<
|
|
722
|
+
any,
|
|
723
|
+
any,
|
|
724
|
+
any,
|
|
725
|
+
any,
|
|
726
|
+
any,
|
|
727
|
+
any,
|
|
728
|
+
any,
|
|
729
|
+
any,
|
|
730
|
+
any,
|
|
731
|
+
any,
|
|
732
|
+
any,
|
|
733
|
+
any,
|
|
734
|
+
any,
|
|
735
|
+
any,
|
|
736
|
+
any,
|
|
737
|
+
any,
|
|
738
|
+
any
|
|
739
|
+
>
|
|
403
740
|
|
|
404
741
|
/**
|
|
405
742
|
* An object type representing the state of a field.
|
|
406
743
|
*/
|
|
407
|
-
export type FieldState<
|
|
744
|
+
export type FieldState<
|
|
745
|
+
TParentData,
|
|
746
|
+
TName extends DeepKeys<TParentData>,
|
|
747
|
+
TData extends DeepValue<TParentData, TName>,
|
|
748
|
+
TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
749
|
+
TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
750
|
+
TOnChangeAsync extends
|
|
751
|
+
| undefined
|
|
752
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
753
|
+
TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
754
|
+
TOnBlurAsync extends
|
|
755
|
+
| undefined
|
|
756
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
757
|
+
TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
758
|
+
TOnSubmitAsync extends
|
|
759
|
+
| undefined
|
|
760
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
761
|
+
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
|
|
762
|
+
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
|
|
763
|
+
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
764
|
+
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
|
|
765
|
+
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
766
|
+
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
|
|
767
|
+
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
768
|
+
> = {
|
|
408
769
|
/**
|
|
409
770
|
* The current value of the field.
|
|
410
771
|
*/
|
|
@@ -412,9 +773,53 @@ export type FieldState<TData> = {
|
|
|
412
773
|
/**
|
|
413
774
|
* The current metadata of the field.
|
|
414
775
|
*/
|
|
415
|
-
meta: FieldMeta
|
|
776
|
+
meta: FieldMeta<
|
|
777
|
+
TParentData,
|
|
778
|
+
TName,
|
|
779
|
+
TData,
|
|
780
|
+
TOnMount,
|
|
781
|
+
TOnChange,
|
|
782
|
+
TOnChangeAsync,
|
|
783
|
+
TOnBlur,
|
|
784
|
+
TOnBlurAsync,
|
|
785
|
+
TOnSubmit,
|
|
786
|
+
TOnSubmitAsync,
|
|
787
|
+
TFormOnMount,
|
|
788
|
+
TFormOnChange,
|
|
789
|
+
TFormOnChangeAsync,
|
|
790
|
+
TFormOnBlur,
|
|
791
|
+
TFormOnBlurAsync,
|
|
792
|
+
TFormOnSubmit,
|
|
793
|
+
TFormOnSubmitAsync
|
|
794
|
+
>
|
|
416
795
|
}
|
|
417
796
|
|
|
797
|
+
/**
|
|
798
|
+
* @public
|
|
799
|
+
*
|
|
800
|
+
* A type representing the Field API with all generics set to `any` for convenience.
|
|
801
|
+
*/
|
|
802
|
+
export type AnyFieldApi = FieldApi<
|
|
803
|
+
any,
|
|
804
|
+
any,
|
|
805
|
+
any,
|
|
806
|
+
any,
|
|
807
|
+
any,
|
|
808
|
+
any,
|
|
809
|
+
any,
|
|
810
|
+
any,
|
|
811
|
+
any,
|
|
812
|
+
any,
|
|
813
|
+
any,
|
|
814
|
+
any,
|
|
815
|
+
any,
|
|
816
|
+
any,
|
|
817
|
+
any,
|
|
818
|
+
any,
|
|
819
|
+
any,
|
|
820
|
+
any
|
|
821
|
+
>
|
|
822
|
+
|
|
418
823
|
/**
|
|
419
824
|
* A class representing the API for managing a form field.
|
|
420
825
|
*
|
|
@@ -427,13 +832,28 @@ export type FieldState<TData> = {
|
|
|
427
832
|
export class FieldApi<
|
|
428
833
|
TParentData,
|
|
429
834
|
TName extends DeepKeys<TParentData>,
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
|
435
|
-
|
|
|
436
|
-
|
|
835
|
+
TData extends DeepValue<TParentData, TName>,
|
|
836
|
+
TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
837
|
+
TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
838
|
+
TOnChangeAsync extends
|
|
839
|
+
| undefined
|
|
840
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
841
|
+
TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
842
|
+
TOnBlurAsync extends
|
|
843
|
+
| undefined
|
|
844
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
845
|
+
TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
846
|
+
TOnSubmitAsync extends
|
|
847
|
+
| undefined
|
|
848
|
+
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
849
|
+
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
|
|
850
|
+
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
|
|
851
|
+
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
852
|
+
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
|
|
853
|
+
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
854
|
+
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
|
|
855
|
+
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
856
|
+
TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
437
857
|
> {
|
|
438
858
|
/**
|
|
439
859
|
* A reference to the form API instance.
|
|
@@ -441,9 +861,22 @@ export class FieldApi<
|
|
|
441
861
|
form: FieldApiOptions<
|
|
442
862
|
TParentData,
|
|
443
863
|
TName,
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
864
|
+
TData,
|
|
865
|
+
TOnMount,
|
|
866
|
+
TOnChange,
|
|
867
|
+
TOnChangeAsync,
|
|
868
|
+
TOnBlur,
|
|
869
|
+
TOnBlurAsync,
|
|
870
|
+
TOnSubmit,
|
|
871
|
+
TOnSubmitAsync,
|
|
872
|
+
TFormOnMount,
|
|
873
|
+
TFormOnChange,
|
|
874
|
+
TFormOnChangeAsync,
|
|
875
|
+
TFormOnBlur,
|
|
876
|
+
TFormOnBlurAsync,
|
|
877
|
+
TFormOnSubmit,
|
|
878
|
+
TFormOnSubmitAsync,
|
|
879
|
+
TFormOnServer
|
|
447
880
|
>['form']
|
|
448
881
|
/**
|
|
449
882
|
* The field name.
|
|
@@ -455,14 +888,47 @@ export class FieldApi<
|
|
|
455
888
|
options: FieldApiOptions<
|
|
456
889
|
TParentData,
|
|
457
890
|
TName,
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
891
|
+
TData,
|
|
892
|
+
TOnMount,
|
|
893
|
+
TOnChange,
|
|
894
|
+
TOnChangeAsync,
|
|
895
|
+
TOnBlur,
|
|
896
|
+
TOnBlurAsync,
|
|
897
|
+
TOnSubmit,
|
|
898
|
+
TOnSubmitAsync,
|
|
899
|
+
TFormOnMount,
|
|
900
|
+
TFormOnChange,
|
|
901
|
+
TFormOnChangeAsync,
|
|
902
|
+
TFormOnBlur,
|
|
903
|
+
TFormOnBlurAsync,
|
|
904
|
+
TFormOnSubmit,
|
|
905
|
+
TFormOnSubmitAsync,
|
|
906
|
+
TFormOnServer
|
|
461
907
|
> = {} as any
|
|
462
908
|
/**
|
|
463
909
|
* The field state store.
|
|
464
910
|
*/
|
|
465
|
-
store!: Derived<
|
|
911
|
+
store!: Derived<
|
|
912
|
+
FieldState<
|
|
913
|
+
TParentData,
|
|
914
|
+
TName,
|
|
915
|
+
TData,
|
|
916
|
+
TOnMount,
|
|
917
|
+
TOnChange,
|
|
918
|
+
TOnChangeAsync,
|
|
919
|
+
TOnBlur,
|
|
920
|
+
TOnBlurAsync,
|
|
921
|
+
TOnSubmit,
|
|
922
|
+
TOnSubmitAsync,
|
|
923
|
+
TFormOnMount,
|
|
924
|
+
TFormOnChange,
|
|
925
|
+
TFormOnChangeAsync,
|
|
926
|
+
TFormOnBlur,
|
|
927
|
+
TFormOnBlurAsync,
|
|
928
|
+
TFormOnSubmit,
|
|
929
|
+
TFormOnSubmitAsync
|
|
930
|
+
>
|
|
931
|
+
>
|
|
466
932
|
/**
|
|
467
933
|
* The current field state.
|
|
468
934
|
*/
|
|
@@ -478,9 +944,22 @@ export class FieldApi<
|
|
|
478
944
|
opts: FieldApiOptions<
|
|
479
945
|
TParentData,
|
|
480
946
|
TName,
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
947
|
+
TData,
|
|
948
|
+
TOnMount,
|
|
949
|
+
TOnChange,
|
|
950
|
+
TOnChangeAsync,
|
|
951
|
+
TOnBlur,
|
|
952
|
+
TOnBlurAsync,
|
|
953
|
+
TOnSubmit,
|
|
954
|
+
TOnSubmitAsync,
|
|
955
|
+
TFormOnMount,
|
|
956
|
+
TFormOnChange,
|
|
957
|
+
TFormOnChangeAsync,
|
|
958
|
+
TFormOnBlur,
|
|
959
|
+
TFormOnBlurAsync,
|
|
960
|
+
TFormOnSubmit,
|
|
961
|
+
TFormOnSubmitAsync,
|
|
962
|
+
TFormOnServer
|
|
484
963
|
>,
|
|
485
964
|
) {
|
|
486
965
|
this.form = opts.form as never
|
|
@@ -510,7 +989,25 @@ export class FieldApi<
|
|
|
510
989
|
return {
|
|
511
990
|
value,
|
|
512
991
|
meta,
|
|
513
|
-
} as FieldState<
|
|
992
|
+
} as FieldState<
|
|
993
|
+
TParentData,
|
|
994
|
+
TName,
|
|
995
|
+
TData,
|
|
996
|
+
TOnMount,
|
|
997
|
+
TOnChange,
|
|
998
|
+
TOnChangeAsync,
|
|
999
|
+
TOnBlur,
|
|
1000
|
+
TOnBlurAsync,
|
|
1001
|
+
TOnSubmit,
|
|
1002
|
+
TOnSubmitAsync,
|
|
1003
|
+
TFormOnMount,
|
|
1004
|
+
TFormOnChange,
|
|
1005
|
+
TFormOnChangeAsync,
|
|
1006
|
+
TFormOnBlur,
|
|
1007
|
+
TFormOnBlurAsync,
|
|
1008
|
+
TFormOnSubmit,
|
|
1009
|
+
TFormOnSubmitAsync
|
|
1010
|
+
>
|
|
514
1011
|
},
|
|
515
1012
|
})
|
|
516
1013
|
|
|
@@ -521,38 +1018,20 @@ export class FieldApi<
|
|
|
521
1018
|
* @private
|
|
522
1019
|
*/
|
|
523
1020
|
runValidator<
|
|
524
|
-
TValue extends {
|
|
525
|
-
|
|
526
|
-
fieldApi: FieldApi<any, any, any, any>
|
|
527
|
-
validationSource: ValidationSource
|
|
1021
|
+
TValue extends TStandardSchemaValidatorValue<TData> & {
|
|
1022
|
+
fieldApi: AnyFieldApi
|
|
528
1023
|
},
|
|
529
1024
|
TType extends 'validate' | 'validateAsync',
|
|
530
1025
|
>(props: {
|
|
531
1026
|
validate: TType extends 'validate'
|
|
532
|
-
? FieldValidateOrFn<any, any, any
|
|
533
|
-
: FieldAsyncValidateOrFn<any, any, any
|
|
1027
|
+
? FieldValidateOrFn<any, any, any>
|
|
1028
|
+
: FieldAsyncValidateOrFn<any, any, any>
|
|
534
1029
|
value: TValue
|
|
535
1030
|
type: TType
|
|
536
1031
|
// When `api` is 'field', the return type cannot be `FormValidationError`
|
|
537
|
-
}):
|
|
538
|
-
const adapters = [
|
|
539
|
-
this.form.options.validatorAdapter,
|
|
540
|
-
this.options.validatorAdapter,
|
|
541
|
-
] as const
|
|
542
|
-
for (const adapter of adapters) {
|
|
543
|
-
if (
|
|
544
|
-
adapter &&
|
|
545
|
-
(typeof props.validate !== 'function' || '~standard' in props.validate)
|
|
546
|
-
) {
|
|
547
|
-
return adapter()[props.type](
|
|
548
|
-
props.value as never,
|
|
549
|
-
props.validate,
|
|
550
|
-
) as never
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
1032
|
+
}): unknown {
|
|
554
1033
|
if (isStandardSchemaValidator(props.validate)) {
|
|
555
|
-
return
|
|
1034
|
+
return standardSchemaValidators[props.type](
|
|
556
1035
|
props.value,
|
|
557
1036
|
props.validate,
|
|
558
1037
|
) as never
|
|
@@ -584,11 +1063,14 @@ export class FieldApi<
|
|
|
584
1063
|
type: 'validate',
|
|
585
1064
|
})
|
|
586
1065
|
if (error) {
|
|
587
|
-
this.setMeta(
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
1066
|
+
this.setMeta(
|
|
1067
|
+
(prev) =>
|
|
1068
|
+
({
|
|
1069
|
+
...prev,
|
|
1070
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1071
|
+
errorMap: { ...prev?.errorMap, onMount: error },
|
|
1072
|
+
}) as never,
|
|
1073
|
+
)
|
|
592
1074
|
}
|
|
593
1075
|
}
|
|
594
1076
|
|
|
@@ -607,9 +1089,22 @@ export class FieldApi<
|
|
|
607
1089
|
opts: FieldApiOptions<
|
|
608
1090
|
TParentData,
|
|
609
1091
|
TName,
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
1092
|
+
TData,
|
|
1093
|
+
TOnMount,
|
|
1094
|
+
TOnChange,
|
|
1095
|
+
TOnChangeAsync,
|
|
1096
|
+
TOnBlur,
|
|
1097
|
+
TOnBlurAsync,
|
|
1098
|
+
TOnSubmit,
|
|
1099
|
+
TOnSubmitAsync,
|
|
1100
|
+
TFormOnMount,
|
|
1101
|
+
TFormOnChange,
|
|
1102
|
+
TFormOnChangeAsync,
|
|
1103
|
+
TFormOnBlur,
|
|
1104
|
+
TFormOnBlurAsync,
|
|
1105
|
+
TFormOnSubmit,
|
|
1106
|
+
TFormOnSubmitAsync,
|
|
1107
|
+
TFormOnServer
|
|
613
1108
|
>,
|
|
614
1109
|
) => {
|
|
615
1110
|
// Default Value
|
|
@@ -664,8 +1159,29 @@ export class FieldApi<
|
|
|
664
1159
|
/**
|
|
665
1160
|
* Sets the field metadata.
|
|
666
1161
|
*/
|
|
667
|
-
setMeta = (
|
|
668
|
-
|
|
1162
|
+
setMeta = (
|
|
1163
|
+
updater: Updater<
|
|
1164
|
+
FieldMeta<
|
|
1165
|
+
TParentData,
|
|
1166
|
+
TName,
|
|
1167
|
+
TData,
|
|
1168
|
+
TOnMount,
|
|
1169
|
+
TOnChange,
|
|
1170
|
+
TOnChangeAsync,
|
|
1171
|
+
TOnBlur,
|
|
1172
|
+
TOnBlurAsync,
|
|
1173
|
+
TOnSubmit,
|
|
1174
|
+
TOnSubmitAsync,
|
|
1175
|
+
TFormOnMount,
|
|
1176
|
+
TFormOnChange,
|
|
1177
|
+
TFormOnChangeAsync,
|
|
1178
|
+
TFormOnBlur,
|
|
1179
|
+
TFormOnBlurAsync,
|
|
1180
|
+
TFormOnSubmit,
|
|
1181
|
+
TFormOnSubmitAsync
|
|
1182
|
+
>
|
|
1183
|
+
>,
|
|
1184
|
+
) => this.form.setFieldMeta(this.name, updater)
|
|
669
1185
|
|
|
670
1186
|
/**
|
|
671
1187
|
* Gets the field information object.
|
|
@@ -720,12 +1236,9 @@ export class FieldApi<
|
|
|
720
1236
|
* @private
|
|
721
1237
|
*/
|
|
722
1238
|
getLinkedFields = (cause: ValidationCause) => {
|
|
723
|
-
const fields = Object.values(this.form.fieldInfo) as FieldInfo<
|
|
724
|
-
any,
|
|
725
|
-
TFormValidator
|
|
726
|
-
>[]
|
|
1239
|
+
const fields = Object.values(this.form.fieldInfo) as FieldInfo<any>[]
|
|
727
1240
|
|
|
728
|
-
const linkedFields:
|
|
1241
|
+
const linkedFields: AnyFieldApi[] = []
|
|
729
1242
|
for (const field of fields) {
|
|
730
1243
|
if (!field.instance) continue
|
|
731
1244
|
const { onChangeListenTo, onBlurListenTo } =
|
|
@@ -762,7 +1275,11 @@ export class FieldApi<
|
|
|
762
1275
|
})
|
|
763
1276
|
return acc.concat(fieldValidates as never)
|
|
764
1277
|
},
|
|
765
|
-
[] as Array<
|
|
1278
|
+
[] as Array<
|
|
1279
|
+
SyncValidator<any> & {
|
|
1280
|
+
field: AnyFieldApi
|
|
1281
|
+
}
|
|
1282
|
+
>,
|
|
766
1283
|
)
|
|
767
1284
|
|
|
768
1285
|
// Needs type cast as eslint errantly believes this is always falsy
|
|
@@ -770,7 +1287,7 @@ export class FieldApi<
|
|
|
770
1287
|
|
|
771
1288
|
batch(() => {
|
|
772
1289
|
const validateFieldFn = (
|
|
773
|
-
field:
|
|
1290
|
+
field: AnyFieldApi,
|
|
774
1291
|
validateObj: SyncValidator<any>,
|
|
775
1292
|
) => {
|
|
776
1293
|
const errorMapKey = getErrorMapKey(validateObj.cause)
|
|
@@ -850,7 +1367,18 @@ export class FieldApi<
|
|
|
850
1367
|
validateAsync = async (
|
|
851
1368
|
cause: ValidationCause,
|
|
852
1369
|
formValidationResultPromise: Promise<
|
|
853
|
-
|
|
1370
|
+
FieldErrorMapFromValidator<
|
|
1371
|
+
TParentData,
|
|
1372
|
+
TName,
|
|
1373
|
+
TData,
|
|
1374
|
+
TOnMount,
|
|
1375
|
+
TOnChange,
|
|
1376
|
+
TOnChangeAsync,
|
|
1377
|
+
TOnBlur,
|
|
1378
|
+
TOnBlurAsync,
|
|
1379
|
+
TOnSubmit,
|
|
1380
|
+
TOnSubmitAsync
|
|
1381
|
+
>
|
|
854
1382
|
>,
|
|
855
1383
|
) => {
|
|
856
1384
|
const validates = getAsyncValidatorArray(cause, this.options)
|
|
@@ -868,7 +1396,9 @@ export class FieldApi<
|
|
|
868
1396
|
return acc.concat(fieldValidates as never)
|
|
869
1397
|
},
|
|
870
1398
|
[] as Array<
|
|
871
|
-
AsyncValidator<any> & {
|
|
1399
|
+
AsyncValidator<any> & {
|
|
1400
|
+
field: AnyFieldApi
|
|
1401
|
+
}
|
|
872
1402
|
>,
|
|
873
1403
|
)
|
|
874
1404
|
|
|
@@ -888,7 +1418,7 @@ export class FieldApi<
|
|
|
888
1418
|
const linkedPromises: Promise<ValidationError | undefined>[] = []
|
|
889
1419
|
|
|
890
1420
|
const validateFieldAsyncFn = (
|
|
891
|
-
field:
|
|
1421
|
+
field: AnyFieldApi,
|
|
892
1422
|
validateObj: AsyncValidator<any>,
|
|
893
1423
|
promises: Promise<ValidationError | undefined>[],
|
|
894
1424
|
) => {
|
|
@@ -957,6 +1487,7 @@ export class FieldApi<
|
|
|
957
1487
|
|
|
958
1488
|
// TODO: Dedupe this logic to reduce bundle size
|
|
959
1489
|
for (const validateObj of validates) {
|
|
1490
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
960
1491
|
if (!validateObj.validate) continue
|
|
961
1492
|
validateFieldAsyncFn(this, validateObj, validatesPromises)
|
|
962
1493
|
}
|
|
@@ -1048,22 +1579,21 @@ export class FieldApi<
|
|
|
1048
1579
|
* Updates the field's errorMap
|
|
1049
1580
|
*/
|
|
1050
1581
|
setErrorMap(errorMap: ValidationErrorMap) {
|
|
1051
|
-
this.setMeta(
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1582
|
+
this.setMeta(
|
|
1583
|
+
(prev) =>
|
|
1584
|
+
({
|
|
1585
|
+
...prev,
|
|
1586
|
+
errorMap: {
|
|
1587
|
+
...prev.errorMap,
|
|
1588
|
+
...errorMap,
|
|
1589
|
+
},
|
|
1590
|
+
}) as never,
|
|
1591
|
+
)
|
|
1058
1592
|
}
|
|
1059
1593
|
}
|
|
1060
1594
|
|
|
1061
1595
|
function normalizeError(rawError?: ValidationError) {
|
|
1062
1596
|
if (rawError) {
|
|
1063
|
-
if (typeof rawError !== 'string') {
|
|
1064
|
-
return 'Invalid Form Values'
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
1597
|
return rawError
|
|
1068
1598
|
}
|
|
1069
1599
|
|