True Myth / standard-schema / ParserFor
Type Alias: ParserFor()<T>
ParserFor<
T
> = (data
) =>ParseResult
<T
>
A type to name a parser, most often used in conjunction with parserFor
. Helpful if you want to use a type you have written to constrain a Standard Schema-compatible schema, instead of creating the type from the schema.
Example
ts
import { parserFor, type ParserFor } from 'true-myth/standard-schema';
import * as z from 'zod';
interface Person {
name?: string | undefined;
age: number;
}
const personParser: ParserFor<Person> = parserFor(z.object({
name: z.string().optional(),
age: z.number().nonnegative(),
}));
Type Parameters
T
T
Parameters
data
unknown
Returns
ParseResult
<T
>