Type Alias InferSchema<T>

InferSchema: T extends Validator<infer V, any>
    ? V
    : T extends Record<string, Validator<unknown, unknown>>
        ? { [Key in keyof T]: InferSchema<T[Key]> }
        : never

Infers the schema type from a schema validator.

Type Parameters

  • T
const schema = avery.object({
name: avery.string(),
age: avery.number(),
});
type Schema = InferSchema<typeof schema>;
// ^^^^^^ = { name: string, age: number }