UNPKG

@stacksjs/ts-validation

Version:

A simple TypeScript starter kit using Bun.

75 lines (72 loc) 2.96 kB
import type { ArrayValidatorType } from './array'; import type { BigintValidatorType, NumberValidatorType } from './number'; import type { BinaryValidatorType } from './binary'; import type { BlobValidatorType } from './blob'; import type { BooleanValidatorType } from './boolean'; import type { CustomValidatorType } from './custom'; import type { DateValidatorType, DatetimeValidatorType } from './date'; import type { DecimalValidatorType } from './decimal'; import type { DoubleValidatorType } from './double'; import type { EnumValidatorType } from './enum'; import type { FloatValidatorType } from './float'; import type { IntegerValidatorType } from './integer'; import type { JsonValidatorType } from './json'; import type { ObjectValidatorType } from './object'; import type { PasswordValidatorType } from './password'; import type { SmallintValidatorType } from './smallint'; import type { StringValidatorType, TextValidatorType } from './string'; import type { TimeValidatorType } from './time'; import type { TimestampTzValidatorType } from './timestamptz'; import type { TimestampValidatorType, UnixValidatorType } from './timestamp'; import type { Validator } from './base'; export declare interface ValidationInstance { string: () => StringValidatorType text: () => TextValidatorType number: () => NumberValidatorType bigint: () => BigintValidatorType array: <T>() => ArrayValidatorType<T> boolean: () => BooleanValidatorType enum: (values: readonly string[]) => EnumValidatorType date: () => DateValidatorType datetime: () => DatetimeValidatorType object: <T extends Record<string, any>>(schema?: Record<string, Validator<any>>) => ObjectValidatorType<T> custom: <T>(validationFn: (value: T) => boolean, message: string) => CustomValidatorType<T> timestamp: () => TimestampValidatorType timestampTz: () => TimestampTzValidatorType unix: () => UnixValidatorType password: () => PasswordValidatorType float: () => FloatValidatorType double: () => DoubleValidatorType decimal: () => DecimalValidatorType time: () => TimeValidatorType smallint: () => SmallintValidatorType integer: () => IntegerValidatorType json: () => JsonValidatorType blob: () => BlobValidatorType binary: () => BinaryValidatorType } export declare type ValidationType = { [K in keyof ValidationInstance]: ReturnType<ValidationInstance[K]> }[keyof ValidationInstance] export * from './array' export * from './base' export * from './binary' export * from './blob' export * from './boolean' export * from './custom' export * from './date' export * from './decimal' export * from './double' export * from './enum' export * from './float' export * from './integer' export * from './json' export * from './number' export * from './object' export * from './options' export * from './password' export * from './smallint' export * from './string' export * from './time' export * from './timestamp' export * from './timestamptz'