@tanstack/form-core 1.24.2 → 1.24.3

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/src/FormApi.ts CHANGED
@@ -2318,13 +2318,18 @@ export class FormApi<
2318
2318
  mergeOpts(options, { dontValidate: true }),
2319
2319
  )
2320
2320
 
2321
- // Validate the whole array + all fields that have shifted
2322
- await this.validateField(field, 'change')
2321
+ const dontValidate = options?.dontValidate ?? false
2322
+ if (!dontValidate) {
2323
+ // Validate the whole array + all fields that have shifted
2324
+ await this.validateField(field, 'change')
2325
+ }
2323
2326
 
2324
2327
  // Shift down all meta after validating to make sure the new field has been mounted
2325
2328
  metaHelper(this).handleArrayFieldMetaShift(field, index, 'insert')
2326
2329
 
2327
- await this.validateArrayFieldsStartingFrom(field, index, 'change')
2330
+ if (!dontValidate) {
2331
+ await this.validateArrayFieldsStartingFrom(field, index, 'change')
2332
+ }
2328
2333
  }
2329
2334
 
2330
2335
  /**
@@ -2348,9 +2353,12 @@ export class FormApi<
2348
2353
  mergeOpts(options, { dontValidate: true }),
2349
2354
  )
2350
2355
 
2351
- // Validate the whole array + all fields that have shifted
2352
- await this.validateField(field, 'change')
2353
- await this.validateArrayFieldsStartingFrom(field, index, 'change')
2356
+ const dontValidate = options?.dontValidate ?? false
2357
+ if (!dontValidate) {
2358
+ // Validate the whole array + all fields that have shifted
2359
+ await this.validateField(field, 'change')
2360
+ await this.validateArrayFieldsStartingFrom(field, index, 'change')
2361
+ }
2354
2362
  }
2355
2363
 
2356
2364
  /**
@@ -2385,9 +2393,12 @@ export class FormApi<
2385
2393
  this.deleteField(start as never)
2386
2394
  }
2387
2395
 
2388
- // Validate the whole array + all fields that have shifted
2389
- await this.validateField(field, 'change')
2390
- await this.validateArrayFieldsStartingFrom(field, index, 'change')
2396
+ const dontValidate = options?.dontValidate ?? false
2397
+ if (!dontValidate) {
2398
+ // Validate the whole array + all fields that have shifted
2399
+ await this.validateField(field, 'change')
2400
+ await this.validateArrayFieldsStartingFrom(field, index, 'change')
2401
+ }
2391
2402
  }
2392
2403
 
2393
2404
  /**
@@ -2412,11 +2423,14 @@ export class FormApi<
2412
2423
  // Swap meta
2413
2424
  metaHelper(this).handleArrayFieldMetaShift(field, index1, 'swap', index2)
2414
2425
 
2415
- // Validate the whole array
2416
- this.validateField(field, 'change')
2417
- // Validate the swapped fields
2418
- this.validateField(`${field}[${index1}]` as DeepKeys<TFormData>, 'change')
2419
- this.validateField(`${field}[${index2}]` as DeepKeys<TFormData>, 'change')
2426
+ const dontValidate = options?.dontValidate ?? false
2427
+ if (!dontValidate) {
2428
+ // Validate the whole array
2429
+ this.validateField(field, 'change')
2430
+ // Validate the swapped fields
2431
+ this.validateField(`${field}[${index1}]` as DeepKeys<TFormData>, 'change')
2432
+ this.validateField(`${field}[${index2}]` as DeepKeys<TFormData>, 'change')
2433
+ }
2420
2434
  }
2421
2435
 
2422
2436
  /**
@@ -2441,11 +2455,14 @@ export class FormApi<
2441
2455
  // Move meta between index1 and index2
2442
2456
  metaHelper(this).handleArrayFieldMetaShift(field, index1, 'move', index2)
2443
2457
 
2444
- // Validate the whole array
2445
- this.validateField(field, 'change')
2446
- // Validate the moved fields
2447
- this.validateField(`${field}[${index1}]` as DeepKeys<TFormData>, 'change')
2448
- this.validateField(`${field}[${index2}]` as DeepKeys<TFormData>, 'change')
2458
+ const dontValidate = options?.dontValidate ?? false
2459
+ if (!dontValidate) {
2460
+ // Validate the whole array
2461
+ this.validateField(field, 'change')
2462
+ // Validate the moved fields
2463
+ this.validateField(`${field}[${index1}]` as DeepKeys<TFormData>, 'change')
2464
+ this.validateField(`${field}[${index2}]` as DeepKeys<TFormData>, 'change')
2465
+ }
2449
2466
  }
2450
2467
 
2451
2468
  /**
@@ -2474,8 +2491,11 @@ export class FormApi<
2474
2491
  }
2475
2492
  }
2476
2493
 
2477
- // validate array change
2478
- this.validateField(field, 'change')
2494
+ const dontValidate = options?.dontValidate ?? false
2495
+ if (!dontValidate) {
2496
+ // validate array change
2497
+ this.validateField(field, 'change')
2498
+ }
2479
2499
  }
2480
2500
 
2481
2501
  /**