@tanstack/form-core 1.16.0 → 1.17.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 (61) hide show
  1. package/dist/cjs/FieldApi.cjs +48 -40
  2. package/dist/cjs/FieldApi.cjs.map +1 -1
  3. package/dist/cjs/FieldApi.d.cts +33 -30
  4. package/dist/cjs/FieldGroupApi.cjs.map +1 -1
  5. package/dist/cjs/FieldGroupApi.d.cts +6 -6
  6. package/dist/cjs/FormApi.cjs +79 -69
  7. package/dist/cjs/FormApi.cjs.map +1 -1
  8. package/dist/cjs/FormApi.d.cts +40 -35
  9. package/dist/cjs/ValidationLogic.cjs +106 -0
  10. package/dist/cjs/ValidationLogic.cjs.map +1 -0
  11. package/dist/cjs/ValidationLogic.d.cts +47 -0
  12. package/dist/cjs/formOptions.cjs.map +1 -1
  13. package/dist/cjs/formOptions.d.cts +1 -1
  14. package/dist/cjs/index.cjs +3 -0
  15. package/dist/cjs/index.cjs.map +1 -1
  16. package/dist/cjs/index.d.cts +1 -0
  17. package/dist/cjs/mergeForm.cjs.map +1 -1
  18. package/dist/cjs/mergeForm.d.cts +1 -1
  19. package/dist/cjs/metaHelper.cjs.map +1 -1
  20. package/dist/cjs/metaHelper.d.cts +1 -1
  21. package/dist/cjs/standardSchemaValidator.cjs.map +1 -1
  22. package/dist/cjs/types.d.cts +6 -3
  23. package/dist/cjs/utils.cjs +51 -63
  24. package/dist/cjs/utils.cjs.map +1 -1
  25. package/dist/cjs/utils.d.cts +11 -5
  26. package/dist/esm/FieldApi.d.ts +33 -30
  27. package/dist/esm/FieldApi.js +48 -40
  28. package/dist/esm/FieldApi.js.map +1 -1
  29. package/dist/esm/FieldGroupApi.d.ts +6 -6
  30. package/dist/esm/FieldGroupApi.js.map +1 -1
  31. package/dist/esm/FormApi.d.ts +40 -35
  32. package/dist/esm/FormApi.js +79 -69
  33. package/dist/esm/FormApi.js.map +1 -1
  34. package/dist/esm/ValidationLogic.d.ts +47 -0
  35. package/dist/esm/ValidationLogic.js +106 -0
  36. package/dist/esm/ValidationLogic.js.map +1 -0
  37. package/dist/esm/formOptions.d.ts +1 -1
  38. package/dist/esm/formOptions.js.map +1 -1
  39. package/dist/esm/index.d.ts +1 -0
  40. package/dist/esm/index.js +3 -0
  41. package/dist/esm/index.js.map +1 -1
  42. package/dist/esm/mergeForm.d.ts +1 -1
  43. package/dist/esm/mergeForm.js.map +1 -1
  44. package/dist/esm/metaHelper.d.ts +1 -1
  45. package/dist/esm/metaHelper.js.map +1 -1
  46. package/dist/esm/standardSchemaValidator.js.map +1 -1
  47. package/dist/esm/types.d.ts +6 -3
  48. package/dist/esm/utils.d.ts +11 -5
  49. package/dist/esm/utils.js +51 -63
  50. package/dist/esm/utils.js.map +1 -1
  51. package/package.json +16 -3
  52. package/src/FieldApi.ts +185 -14
  53. package/src/FieldGroupApi.ts +14 -0
  54. package/src/FormApi.ts +131 -3
  55. package/src/ValidationLogic.ts +200 -0
  56. package/src/formOptions.ts +1 -1
  57. package/src/index.ts +1 -0
  58. package/src/mergeForm.ts +16 -1
  59. package/src/metaHelper.ts +4 -0
  60. package/src/types.ts +17 -1
  61. package/src/utils.ts +159 -109
package/src/FieldApi.ts CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  getBy,
11
11
  getSyncValidatorArray,
12
12
  } from './utils'
13
+ import { defaultValidationLogic } from './ValidationLogic'
13
14
  import type { DeepKeys, DeepValue, UnwrapOneLevelOfArray } from './util-types'
14
15
  import type {
15
16
  StandardSchemaV1,
@@ -100,6 +101,10 @@ export type FieldValidateFn<
100
101
  any,
101
102
  any,
102
103
  any,
104
+ any,
105
+ any,
106
+ any,
107
+ any,
103
108
  any
104
109
  >
105
110
  }) => unknown
@@ -183,6 +188,10 @@ export type FieldValidateAsyncFn<
183
188
  any,
184
189
  any,
185
190
  any,
191
+ any,
192
+ any,
193
+ any,
194
+ any,
186
195
  any
187
196
  >
188
197
  signal: AbortSignal
@@ -265,6 +274,10 @@ export type FieldListenerFn<
265
274
  any,
266
275
  any,
267
276
  any,
277
+ any,
278
+ any,
279
+ any,
280
+ any,
268
281
  any
269
282
  >
270
283
  }) => void
@@ -286,6 +299,10 @@ export interface FieldValidators<
286
299
  TOnSubmitAsync extends
287
300
  | undefined
288
301
  | FieldAsyncValidateOrFn<TParentData, TName, TData>,
302
+ TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
303
+ TOnDynamicAsync extends
304
+ | undefined
305
+ | FieldAsyncValidateOrFn<TParentData, TName, TData>,
289
306
  > {
290
307
  /**
291
308
  * An optional function, that runs on the mount event of input.
@@ -348,6 +365,9 @@ export interface FieldValidators<
348
365
  * @example z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })
349
366
  */
350
367
  onSubmitAsync?: TOnSubmitAsync
368
+ onDynamic?: TOnDynamic
369
+ onDynamicAsync?: TOnDynamicAsync
370
+ onDynamicAsyncDebounceMs?: number
351
371
  }
352
372
 
353
373
  export interface FieldListeners<
@@ -383,6 +403,10 @@ export interface FieldOptions<
383
403
  TOnSubmitAsync extends
384
404
  | undefined
385
405
  | FieldAsyncValidateOrFn<TParentData, TName, TData>,
406
+ TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
407
+ TOnDynamicAsync extends
408
+ | undefined
409
+ | FieldAsyncValidateOrFn<TParentData, TName, TData>,
386
410
  > {
387
411
  /**
388
412
  * The field name. The type will be `DeepKeys<TParentData>` to ensure your name is a deep key of the parent dataset.
@@ -413,7 +437,9 @@ export interface FieldOptions<
413
437
  TOnBlur,
414
438
  TOnBlurAsync,
415
439
  TOnSubmit,
416
- TOnSubmitAsync
440
+ TOnSubmitAsync,
441
+ TOnDynamic,
442
+ TOnDynamicAsync
417
443
  >
418
444
  /**
419
445
  * An optional object with default metadata for the field.
@@ -430,6 +456,10 @@ export interface FieldOptions<
430
456
  TOnBlurAsync,
431
457
  TOnSubmit,
432
458
  TOnSubmitAsync,
459
+ TOnDynamic,
460
+ TOnDynamicAsync,
461
+ any,
462
+ any,
433
463
  any,
434
464
  any,
435
465
  any,
@@ -477,6 +507,12 @@ export interface FieldApiOptions<
477
507
  in out TOnSubmitAsync extends
478
508
  | undefined
479
509
  | FieldAsyncValidateOrFn<TParentData, TName, TData>,
510
+ in out TOnDynamic extends
511
+ | undefined
512
+ | FieldValidateOrFn<TParentData, TName, TData>,
513
+ in out TOnDynamicAsync extends
514
+ | undefined
515
+ | FieldAsyncValidateOrFn<TParentData, TName, TData>,
480
516
  in out TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
481
517
  in out TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
482
518
  in out TFormOnChangeAsync extends
@@ -490,6 +526,10 @@ export interface FieldApiOptions<
490
526
  in out TFormOnSubmitAsync extends
491
527
  | undefined
492
528
  | FormAsyncValidateOrFn<TParentData>,
529
+ in out TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
530
+ in out TFormOnDynamicAsync extends
531
+ | undefined
532
+ | FormAsyncValidateOrFn<TParentData>,
493
533
  in out TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>,
494
534
  in out TParentSubmitMeta,
495
535
  > extends FieldOptions<
@@ -502,7 +542,9 @@ export interface FieldApiOptions<
502
542
  TOnBlur,
503
543
  TOnBlurAsync,
504
544
  TOnSubmit,
505
- TOnSubmitAsync
545
+ TOnSubmitAsync,
546
+ TOnDynamic,
547
+ TOnDynamicAsync
506
548
  > {
507
549
  form: FormApi<
508
550
  TParentData,
@@ -513,6 +555,8 @@ export interface FieldApiOptions<
513
555
  TFormOnBlurAsync,
514
556
  TFormOnSubmit,
515
557
  TFormOnSubmitAsync,
558
+ TFormOnDynamic,
559
+ TFormOnDynamicAsync,
516
560
  TFormOnServer,
517
561
  TParentSubmitMeta
518
562
  >
@@ -535,6 +579,10 @@ export type FieldMetaBase<
535
579
  TOnSubmitAsync extends
536
580
  | undefined
537
581
  | FieldAsyncValidateOrFn<TParentData, TName, TData>,
582
+ TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
583
+ TOnDynamicAsync extends
584
+ | undefined
585
+ | FieldAsyncValidateOrFn<TParentData, TName, TData>,
538
586
  TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
539
587
  TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
540
588
  TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
@@ -542,6 +590,8 @@ export type FieldMetaBase<
542
590
  TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
543
591
  TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
544
592
  TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
593
+ TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
594
+ TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
545
595
  > = {
546
596
  /**
547
597
  * A flag indicating whether the field has been touched.
@@ -565,8 +615,11 @@ export type FieldMetaBase<
565
615
  UnwrapFieldValidateOrFn<TName, TOnBlur, TFormOnBlur>,
566
616
  UnwrapFieldAsyncValidateOrFn<TName, TOnBlurAsync, TFormOnBlurAsync>,
567
617
  UnwrapFieldValidateOrFn<TName, TOnSubmit, TFormOnSubmit>,
568
- UnwrapFieldAsyncValidateOrFn<TName, TOnSubmitAsync, TFormOnSubmitAsync>
618
+ UnwrapFieldAsyncValidateOrFn<TName, TOnSubmitAsync, TFormOnSubmitAsync>,
619
+ UnwrapFieldValidateOrFn<TName, TOnDynamic, TFormOnDynamic>,
620
+ UnwrapFieldAsyncValidateOrFn<TName, TOnDynamicAsync, TFormOnDynamicAsync>
569
621
  >
622
+
570
623
  /**
571
624
  * @private allows tracking the source of the errors in the error map
572
625
  */
@@ -594,6 +647,10 @@ export type AnyFieldMetaBase = FieldMetaBase<
594
647
  any,
595
648
  any,
596
649
  any,
650
+ any,
651
+ any,
652
+ any,
653
+ any,
597
654
  any
598
655
  >
599
656
 
@@ -614,6 +671,10 @@ export type FieldMetaDerived<
614
671
  TOnSubmitAsync extends
615
672
  | undefined
616
673
  | FieldAsyncValidateOrFn<TParentData, TName, TData>,
674
+ TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
675
+ TOnDynamicAsync extends
676
+ | undefined
677
+ | FieldAsyncValidateOrFn<TParentData, TName, TData>,
617
678
  TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
618
679
  TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
619
680
  TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
@@ -621,6 +682,8 @@ export type FieldMetaDerived<
621
682
  TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
622
683
  TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
623
684
  TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
685
+ TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
686
+ TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
624
687
  > = {
625
688
  /**
626
689
  * An array of errors related to the field value.
@@ -647,6 +710,16 @@ export type FieldMetaDerived<
647
710
  | UnwrapOneLevelOfArray<
648
711
  UnwrapFieldAsyncValidateOrFn<TName, TOnSubmitAsync, TFormOnSubmitAsync>
649
712
  >
713
+ | UnwrapOneLevelOfArray<
714
+ UnwrapFieldValidateOrFn<TName, TOnDynamic, TFormOnDynamic>
715
+ >
716
+ | UnwrapOneLevelOfArray<
717
+ UnwrapFieldAsyncValidateOrFn<
718
+ TName,
719
+ TOnDynamicAsync,
720
+ TFormOnDynamicAsync
721
+ >
722
+ >
650
723
  >
651
724
  /**
652
725
  * A flag that is `true` if the field's value has not been modified by the user. Opposite of `isDirty`.
@@ -679,6 +752,10 @@ export type AnyFieldMetaDerived = FieldMetaDerived<
679
752
  any,
680
753
  any,
681
754
  any,
755
+ any,
756
+ any,
757
+ any,
758
+ any,
682
759
  any
683
760
  >
684
761
 
@@ -702,6 +779,10 @@ export type FieldMeta<
702
779
  TOnSubmitAsync extends
703
780
  | undefined
704
781
  | FieldAsyncValidateOrFn<TParentData, TName, TData>,
782
+ TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
783
+ TOnDynamicAsync extends
784
+ | undefined
785
+ | FieldAsyncValidateOrFn<TParentData, TName, TData>,
705
786
  TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
706
787
  TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
707
788
  TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
@@ -709,6 +790,8 @@ export type FieldMeta<
709
790
  TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
710
791
  TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
711
792
  TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
793
+ TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
794
+ TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
712
795
  > = FieldMetaBase<
713
796
  TParentData,
714
797
  TName,
@@ -720,13 +803,17 @@ export type FieldMeta<
720
803
  TOnBlurAsync,
721
804
  TOnSubmit,
722
805
  TOnSubmitAsync,
806
+ TOnDynamic,
807
+ TOnDynamicAsync,
723
808
  TFormOnMount,
724
809
  TFormOnChange,
725
810
  TFormOnChangeAsync,
726
811
  TFormOnBlur,
727
812
  TFormOnBlurAsync,
728
813
  TFormOnSubmit,
729
- TFormOnSubmitAsync
814
+ TFormOnSubmitAsync,
815
+ TFormOnDynamic,
816
+ TFormOnDynamicAsync
730
817
  > &
731
818
  FieldMetaDerived<
732
819
  TParentData,
@@ -739,13 +826,17 @@ export type FieldMeta<
739
826
  TOnBlurAsync,
740
827
  TOnSubmit,
741
828
  TOnSubmitAsync,
829
+ TOnDynamic,
830
+ TOnDynamicAsync,
742
831
  TFormOnMount,
743
832
  TFormOnChange,
744
833
  TFormOnChangeAsync,
745
834
  TFormOnBlur,
746
835
  TFormOnBlurAsync,
747
836
  TFormOnSubmit,
748
- TFormOnSubmitAsync
837
+ TFormOnSubmitAsync,
838
+ TFormOnDynamic,
839
+ TFormOnDynamicAsync
749
840
  >
750
841
 
751
842
  export type AnyFieldMeta = FieldMeta<
@@ -765,6 +856,10 @@ export type AnyFieldMeta = FieldMeta<
765
856
  any,
766
857
  any,
767
858
  any,
859
+ any,
860
+ any,
861
+ any,
862
+ any,
768
863
  any
769
864
  >
770
865
 
@@ -788,6 +883,10 @@ export type FieldState<
788
883
  TOnSubmitAsync extends
789
884
  | undefined
790
885
  | FieldAsyncValidateOrFn<TParentData, TName, TData>,
886
+ TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
887
+ TOnDynamicAsync extends
888
+ | undefined
889
+ | FieldAsyncValidateOrFn<TParentData, TName, TData>,
791
890
  TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
792
891
  TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
793
892
  TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
@@ -795,6 +894,8 @@ export type FieldState<
795
894
  TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
796
895
  TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
797
896
  TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
897
+ TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
898
+ TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
798
899
  > = {
799
900
  /**
800
901
  * The current value of the field.
@@ -814,13 +915,17 @@ export type FieldState<
814
915
  TOnBlurAsync,
815
916
  TOnSubmit,
816
917
  TOnSubmitAsync,
918
+ TOnDynamic,
919
+ TOnDynamicAsync,
817
920
  TFormOnMount,
818
921
  TFormOnChange,
819
922
  TFormOnChangeAsync,
820
923
  TFormOnBlur,
821
924
  TFormOnBlurAsync,
822
925
  TFormOnSubmit,
823
- TFormOnSubmitAsync
926
+ TFormOnSubmitAsync,
927
+ TFormOnDynamic,
928
+ TFormOnDynamicAsync
824
929
  >
825
930
  }
826
931
 
@@ -848,6 +953,10 @@ export type AnyFieldApi = FieldApi<
848
953
  any,
849
954
  any,
850
955
  any,
956
+ any,
957
+ any,
958
+ any,
959
+ any,
851
960
  any
852
961
  >
853
962
 
@@ -885,6 +994,12 @@ export class FieldApi<
885
994
  in out TOnSubmitAsync extends
886
995
  | undefined
887
996
  | FieldAsyncValidateOrFn<TParentData, TName, TData>,
997
+ in out TOnDynamic extends
998
+ | undefined
999
+ | FieldValidateOrFn<TParentData, TName, TData>,
1000
+ in out TOnDynamicAsync extends
1001
+ | undefined
1002
+ | FieldAsyncValidateOrFn<TParentData, TName, TData>,
888
1003
  in out TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
889
1004
  in out TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
890
1005
  in out TFormOnChangeAsync extends
@@ -898,6 +1013,10 @@ export class FieldApi<
898
1013
  in out TFormOnSubmitAsync extends
899
1014
  | undefined
900
1015
  | FormAsyncValidateOrFn<TParentData>,
1016
+ in out TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
1017
+ in out TFormOnDynamicAsync extends
1018
+ | undefined
1019
+ | FormAsyncValidateOrFn<TParentData>,
901
1020
  in out TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>,
902
1021
  in out TParentSubmitMeta,
903
1022
  > {
@@ -915,6 +1034,8 @@ export class FieldApi<
915
1034
  TOnBlurAsync,
916
1035
  TOnSubmit,
917
1036
  TOnSubmitAsync,
1037
+ TOnDynamic,
1038
+ TOnDynamicAsync,
918
1039
  TFormOnMount,
919
1040
  TFormOnChange,
920
1041
  TFormOnChangeAsync,
@@ -922,6 +1043,8 @@ export class FieldApi<
922
1043
  TFormOnBlurAsync,
923
1044
  TFormOnSubmit,
924
1045
  TFormOnSubmitAsync,
1046
+ TFormOnDynamic,
1047
+ TFormOnDynamicAsync,
925
1048
  TFormOnServer,
926
1049
  TParentSubmitMeta
927
1050
  >['form']
@@ -943,6 +1066,8 @@ export class FieldApi<
943
1066
  TOnBlurAsync,
944
1067
  TOnSubmit,
945
1068
  TOnSubmitAsync,
1069
+ TOnDynamic,
1070
+ TOnDynamicAsync,
946
1071
  TFormOnMount,
947
1072
  TFormOnChange,
948
1073
  TFormOnChangeAsync,
@@ -950,6 +1075,8 @@ export class FieldApi<
950
1075
  TFormOnBlurAsync,
951
1076
  TFormOnSubmit,
952
1077
  TFormOnSubmitAsync,
1078
+ TFormOnDynamic,
1079
+ TFormOnDynamicAsync,
953
1080
  TFormOnServer,
954
1081
  TParentSubmitMeta
955
1082
  > = {} as any
@@ -968,13 +1095,17 @@ export class FieldApi<
968
1095
  TOnBlurAsync,
969
1096
  TOnSubmit,
970
1097
  TOnSubmitAsync,
1098
+ TOnDynamic,
1099
+ TOnDynamicAsync,
971
1100
  TFormOnMount,
972
1101
  TFormOnChange,
973
1102
  TFormOnChangeAsync,
974
1103
  TFormOnBlur,
975
1104
  TFormOnBlurAsync,
976
1105
  TFormOnSubmit,
977
- TFormOnSubmitAsync
1106
+ TFormOnSubmitAsync,
1107
+ TFormOnDynamic,
1108
+ TFormOnDynamicAsync
978
1109
  >
979
1110
  >
980
1111
  /**
@@ -1004,6 +1135,8 @@ export class FieldApi<
1004
1135
  TOnBlurAsync,
1005
1136
  TOnSubmit,
1006
1137
  TOnSubmitAsync,
1138
+ TOnDynamic,
1139
+ TOnDynamicAsync,
1007
1140
  TFormOnMount,
1008
1141
  TFormOnChange,
1009
1142
  TFormOnChangeAsync,
@@ -1011,6 +1144,8 @@ export class FieldApi<
1011
1144
  TFormOnBlurAsync,
1012
1145
  TFormOnSubmit,
1013
1146
  TFormOnSubmitAsync,
1147
+ TFormOnDynamic,
1148
+ TFormOnDynamicAsync,
1014
1149
  TFormOnServer,
1015
1150
  TParentSubmitMeta
1016
1151
  >,
@@ -1046,13 +1181,17 @@ export class FieldApi<
1046
1181
  TOnBlurAsync,
1047
1182
  TOnSubmit,
1048
1183
  TOnSubmitAsync,
1184
+ TOnDynamic,
1185
+ TOnDynamicAsync,
1049
1186
  TFormOnMount,
1050
1187
  TFormOnChange,
1051
1188
  TFormOnChangeAsync,
1052
1189
  TFormOnBlur,
1053
1190
  TFormOnBlurAsync,
1054
1191
  TFormOnSubmit,
1055
- TFormOnSubmitAsync
1192
+ TFormOnSubmitAsync,
1193
+ TFormOnDynamic,
1194
+ TFormOnDynamicAsync
1056
1195
  >
1057
1196
  },
1058
1197
  })
@@ -1154,6 +1293,8 @@ export class FieldApi<
1154
1293
  TOnBlurAsync,
1155
1294
  TOnSubmit,
1156
1295
  TOnSubmitAsync,
1296
+ TOnDynamic,
1297
+ TOnDynamicAsync,
1157
1298
  TFormOnMount,
1158
1299
  TFormOnChange,
1159
1300
  TFormOnChangeAsync,
@@ -1161,6 +1302,8 @@ export class FieldApi<
1161
1302
  TFormOnBlurAsync,
1162
1303
  TFormOnSubmit,
1163
1304
  TFormOnSubmitAsync,
1305
+ TFormOnDynamic,
1306
+ TFormOnDynamicAsync,
1164
1307
  TFormOnServer,
1165
1308
  TParentSubmitMeta
1166
1309
  >,
@@ -1232,13 +1375,17 @@ export class FieldApi<
1232
1375
  TOnBlurAsync,
1233
1376
  TOnSubmit,
1234
1377
  TOnSubmitAsync,
1378
+ TOnDynamic,
1379
+ TOnDynamicAsync,
1235
1380
  TFormOnMount,
1236
1381
  TFormOnChange,
1237
1382
  TFormOnChangeAsync,
1238
1383
  TFormOnBlur,
1239
1384
  TFormOnBlurAsync,
1240
1385
  TFormOnSubmit,
1241
- TFormOnSubmitAsync
1386
+ TFormOnSubmitAsync,
1387
+ TFormOnDynamic,
1388
+ TFormOnDynamicAsync
1242
1389
  >
1243
1390
  >,
1244
1391
  ) => this.form.setFieldMeta(this.name, updater)
@@ -1351,12 +1498,22 @@ export class FieldApi<
1351
1498
  cause: ValidationCause,
1352
1499
  errorFromForm: ValidationErrorMap,
1353
1500
  ) => {
1354
- const validates = getSyncValidatorArray(cause, this.options)
1501
+ const validates = getSyncValidatorArray(cause, {
1502
+ ...this.options,
1503
+ form: this.form,
1504
+ validationLogic:
1505
+ this.form.options.validationLogic || defaultValidationLogic,
1506
+ })
1355
1507
 
1356
1508
  const linkedFields = this.getLinkedFields(cause)
1357
1509
  const linkedFieldValidates = linkedFields.reduce(
1358
1510
  (acc, field) => {
1359
- const fieldValidates = getSyncValidatorArray(cause, field.options)
1511
+ const fieldValidates = getSyncValidatorArray(cause, {
1512
+ ...field.options,
1513
+ form: field.form,
1514
+ validationLogic:
1515
+ field.form.options.validationLogic || defaultValidationLogic,
1516
+ })
1360
1517
  fieldValidates.forEach((validate) => {
1361
1518
  ;(validate as any).field = field
1362
1519
  })
@@ -1477,7 +1634,12 @@ export class FieldApi<
1477
1634
  >
1478
1635
  >,
1479
1636
  ) => {
1480
- const validates = getAsyncValidatorArray(cause, this.options)
1637
+ const validates = getAsyncValidatorArray(cause, {
1638
+ ...this.options,
1639
+ form: this.form,
1640
+ validationLogic:
1641
+ this.form.options.validationLogic || defaultValidationLogic,
1642
+ })
1481
1643
 
1482
1644
  // Get the field-specific error messages that are coming from the form's validator
1483
1645
  const asyncFormValidationResults = await formValidationResultPromise
@@ -1485,7 +1647,12 @@ export class FieldApi<
1485
1647
  const linkedFields = this.getLinkedFields(cause)
1486
1648
  const linkedFieldValidates = linkedFields.reduce(
1487
1649
  (acc, field) => {
1488
- const fieldValidates = getAsyncValidatorArray(cause, field.options)
1650
+ const fieldValidates = getAsyncValidatorArray(cause, {
1651
+ ...field.options,
1652
+ form: field.form,
1653
+ validationLogic:
1654
+ field.form.options.validationLogic || defaultValidationLogic,
1655
+ })
1489
1656
  fieldValidates.forEach((validate) => {
1490
1657
  ;(validate as any).field = field
1491
1658
  })
@@ -1691,7 +1858,9 @@ export class FieldApi<
1691
1858
  UnwrapFieldValidateOrFn<TName, TOnBlur, TFormOnBlur>,
1692
1859
  UnwrapFieldAsyncValidateOrFn<TName, TOnBlurAsync, TFormOnBlurAsync>,
1693
1860
  UnwrapFieldValidateOrFn<TName, TOnSubmit, TFormOnSubmit>,
1694
- UnwrapFieldAsyncValidateOrFn<TName, TOnSubmitAsync, TFormOnSubmitAsync>
1861
+ UnwrapFieldAsyncValidateOrFn<TName, TOnSubmitAsync, TFormOnSubmitAsync>,
1862
+ UnwrapFieldValidateOrFn<TName, TOnDynamic, TFormOnDynamic>,
1863
+ UnwrapFieldAsyncValidateOrFn<TName, TOnDynamicAsync, TFormOnDynamicAsync>
1695
1864
  >,
1696
1865
  ) {
1697
1866
  this.setMeta((prev) => ({
@@ -1826,6 +1995,8 @@ function getErrorMapKey(cause: ValidationCause) {
1826
1995
  return 'onMount'
1827
1996
  case 'server':
1828
1997
  return 'onServer'
1998
+ case 'dynamic':
1999
+ return 'onDynamic'
1829
2000
  case 'change':
1830
2001
  default:
1831
2002
  return 'onChange'
@@ -31,6 +31,8 @@ export type AnyFieldGroupApi = FieldGroupApi<
31
31
  any,
32
32
  any,
33
33
  any,
34
+ any,
35
+ any,
34
36
  any
35
37
  >
36
38
 
@@ -57,6 +59,8 @@ export interface FieldGroupOptions<
57
59
  in out TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
58
60
  in out TOnSubmit extends undefined | FormValidateOrFn<TFormData>,
59
61
  in out TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
62
+ in out TOnDynamic extends undefined | FormValidateOrFn<TFormData>,
63
+ in out TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
60
64
  in out TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>,
61
65
  in out TSubmitMeta = never,
62
66
  > {
@@ -70,6 +74,8 @@ export interface FieldGroupOptions<
70
74
  TOnBlurAsync,
71
75
  TOnSubmit,
72
76
  TOnSubmitAsync,
77
+ TOnDynamic,
78
+ TOnDynamicAsync,
73
79
  TOnServer,
74
80
  TSubmitMeta
75
81
  >
@@ -85,6 +91,8 @@ export interface FieldGroupOptions<
85
91
  any,
86
92
  any,
87
93
  any,
94
+ any,
95
+ any,
88
96
  TSubmitMeta
89
97
  >
90
98
  /**
@@ -114,6 +122,8 @@ export class FieldGroupApi<
114
122
  in out TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
115
123
  in out TOnSubmit extends undefined | FormValidateOrFn<TFormData>,
116
124
  in out TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
125
+ in out TOnDynamic extends undefined | FormValidateOrFn<TFormData>,
126
+ in out TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>,
117
127
  in out TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>,
118
128
  in out TSubmitMeta = never,
119
129
  > implements FieldManipulator<TFieldGroupData, TSubmitMeta>
@@ -130,6 +140,8 @@ export class FieldGroupApi<
130
140
  TOnBlurAsync,
131
141
  TOnSubmit,
132
142
  TOnSubmitAsync,
143
+ TOnDynamic,
144
+ TOnDynamicAsync,
133
145
  TOnServer,
134
146
  TSubmitMeta
135
147
  >
@@ -184,6 +196,8 @@ export class FieldGroupApi<
184
196
  TOnBlurAsync,
185
197
  TOnSubmit,
186
198
  TOnSubmitAsync,
199
+ TOnDynamic,
200
+ TOnDynamicAsync,
187
201
  TOnServer,
188
202
  TSubmitMeta
189
203
  >,