Open History to see the last commit
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 }
18}