Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

index.ts

18 lines551 Bytes

1import { parse } from 'valibot'
2import type { ValidatorAdapter } from '@tanstack/react-router'
3import type { GenericSchema, InferInput, InferOutput } from 'valibot'
4​
5export type ValibotValidatorAdapter<TOptions extends GenericSchema> =
6 ValidatorAdapter<InferInput<TOptions>, InferOutput<TOptions>>
7​
8export const valibotValidator = <TOptions extends GenericSchema>(
9 options: TOptions,
10): ValibotValidatorAdapter<TOptions> => {
11 return {
12 types: {
13 input: null,
14 output: null,
15 },
16 parse: (input) => parse(options, input),
17 }