UNPKG

typescript-runtime-schemas

Version:

A TypeScript schema generation tool that extracts Zod schemas from TypeScript source files with runtime validation support. Generate validation schemas directly from your existing TypeScript types with support for computed types and constraint-based valid

35 lines (34 loc) 1.44 kB
/** * Constraint Type Definitions * * This file contains all the constraint types used for runtime validation. * These types are automatically loaded by the SchemaExtractor to ensure * consistency between the type definitions and the schema extraction process. */ export type SupportsRuntimeValidation = {}; export type Constraint<K extends any> = {}; export type Min<N extends number> = Constraint<N>; export type Max<N extends number> = Constraint<N>; export type Integer = Constraint<number>; export type Positive = Constraint<number>; export type Negative = Constraint<number>; export type MinLength<N extends number> = Constraint<N>; export type MaxLength<N extends number> = Constraint<N>; export type Email = Constraint<string>; export type Regex<P extends string> = Constraint<P>; export type UUID = Constraint<string>; export type URL = Constraint<string>; export type Date = Constraint<string>; export type NonEmpty = Constraint<string>; export type Phone = Constraint<string>; export type CreditCard = Constraint<string>; export type IPAddress = Constraint<string>; export type Base64 = Constraint<string>; export type JSON = Constraint<string>; export type Range<Min extends number, Max extends number> = Constraint<{ min: Min; max: Max; }>; export type OneOf<T extends readonly string[]> = Constraint<T>; export type FileSize<N extends number> = Constraint<N>; export type MimeType<T extends string> = Constraint<T>;