@tanstack/react-router 1.81.3 → 1.81.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.81.3",
3
+ "version": "1.81.4",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/route.ts CHANGED
@@ -515,9 +515,13 @@ export interface SearchValidatorAdapter<TInput, TOutput> {
515
515
 
516
516
  export type AnySearchValidatorAdapter = SearchValidatorAdapter<any, any>
517
517
 
518
+ export interface StandardSchemaValidatorProps<TInput, TOutput> {
519
+ readonly types?: StandardSchemaValidatorTypes<TInput, TOutput> | undefined
520
+ readonly validate: AnyStandardSchemaValidate
521
+ }
522
+
518
523
  export interface StandardSchemaValidator<TInput, TOutput> {
519
- readonly '~types'?: StandardSchemaValidatorTypes<TInput, TOutput> | undefined
520
- readonly '~validate': AnyStandardSchemaValidate
524
+ readonly '~standard': StandardSchemaValidatorProps<TInput, TOutput>
521
525
  }
522
526
 
523
527
  export type AnyStandardSchemaValidator = StandardSchemaValidator<any, any>
@@ -529,6 +533,7 @@ export interface StandardSchemaValidatorTypes<TInput, TOutput> {
529
533
 
530
534
  export interface AnyStandardSchemaValidateSuccess {
531
535
  readonly value: any
536
+ readonly issues?: undefined
532
537
  }
533
538
 
534
539
  export interface AnyStandardSchemaValidateFailure {
@@ -539,13 +544,11 @@ export interface AnyStandardSchemaValidateIssue {
539
544
  readonly message: string
540
545
  }
541
546
 
542
- export interface AnyStandardSchemaValidateInput {
543
- readonly value: any
544
- }
545
-
546
547
  export type AnyStandardSchemaValidate = (
547
- input: AnyStandardSchemaValidateInput,
548
- ) => AnyStandardSchemaValidateSuccess | AnyStandardSchemaValidateFailure
548
+ value: unknown,
549
+ ) =>
550
+ | (AnyStandardSchemaValidateSuccess | AnyStandardSchemaValidateFailure)
551
+ | Promise<AnyStandardSchemaValidateSuccess | AnyStandardSchemaValidateFailure>
549
552
 
550
553
  export type AnySearchValidatorFn = SearchValidatorFn<any, any>
551
554
 
@@ -681,7 +684,7 @@ export type ResolveSearchSchemaFnInput<TSearchValidator> =
681
684
 
682
685
  export type ResolveSearchSchemaInput<TSearchValidator> =
683
686
  TSearchValidator extends AnyStandardSchemaValidator
684
- ? NonNullable<TSearchValidator['~types']>['input']
687
+ ? NonNullable<TSearchValidator['~standard']['types']>['input']
685
688
  : TSearchValidator extends AnySearchValidatorAdapter
686
689
  ? TSearchValidator['types']['input']
687
690
  : TSearchValidator extends AnySearchValidatorObj
@@ -698,7 +701,7 @@ export type ResolveSearchSchema<TSearchValidator> =
698
701
  unknown extends TSearchValidator
699
702
  ? TSearchValidator
700
703
  : TSearchValidator extends AnyStandardSchemaValidator
701
- ? NonNullable<TSearchValidator['~types']>['output']
704
+ ? NonNullable<TSearchValidator['~standard']['types']>['output']
702
705
  : TSearchValidator extends AnySearchValidatorAdapter
703
706
  ? TSearchValidator['types']['output']
704
707
  : TSearchValidator extends AnySearchValidatorObj
package/src/router.ts CHANGED
@@ -585,11 +585,14 @@ function validateSearch(
585
585
  ): unknown {
586
586
  if (validateSearch == null) return {}
587
587
 
588
- if ('~validate' in validateSearch) {
589
- const result = validateSearch['~validate']({ value: input })
588
+ if ('~standard' in validateSearch) {
589
+ const result = validateSearch['~standard'].validate(input)
590
590
 
591
591
  if ('value' in result) return result.value
592
592
 
593
+ if (result instanceof Promise)
594
+ throw new SearchParamError('Async validation not supported')
595
+
593
596
  throw new SearchParamError(JSON.stringify(result.issues, undefined, 2))
594
597
  }
595
598