Closed y-nk closed 1 month ago
This works but you can't use an action as the first argument of pipe
. See this playground.
import * as v from 'valibot';
const myCustomValidator = (length: number) => v.pipe(
v.string(),
v.maxLength(length),
)
const MySchema = v.object({
someString: v.pipe(
v.string(), // <-- Schema required
myCustomValidator(1),
)
});
ah, i see. thanks for this, it makes sense.
I'm trying to write custom validators and i thought i could do something like:
of course, this is a dumb example and i know i can probably get out with:
but i'd be loosing type safety of the
pipe
call in themyCustomValidator
function... so i was curious if this could be done, and how?