UNPKG

bookish-potato-dto

Version:

## Overview A TypeScript decorators-based API for defining Data Transfer Object (DTO) classes, types, and parsers. Simplifies schema validation and type enforcement using intuitive decorators and TypeScript classes.

31 lines (30 loc) 1.74 kB
import { PropertyParser, Range } from '../types'; import { ClassType, EnumAllowedGenericType, EnumType } from '../_types'; export declare abstract class PropertyParsers { private static readonly cache; /** * Returns a cached parser or creates a new one. * Can be used to cache parsers by key. * @param key - unique key for the parser. * @param factory - factory function to create a new parser. */ static CACHE_PARSER<T>(key: string, factory: () => PropertyParser<T>): PropertyParser<T>; static get STRING(): PropertyParser<string>; static STRING_IN_RANGE(range: Partial<Range>): PropertyParser<string>; static STRING_REGEX(regex: RegExp): PropertyParser<string>; static get NUMBER(): PropertyParser<number>; static NUMBER_IN_RANGE(range: Partial<Range>): PropertyParser<number>; static get STRING_TO_NUMBER(): PropertyParser<number>; static STRING_TO_NUMBER_IN_RANGE(range: Partial<Range>): PropertyParser<number>; static get INTEGER(): PropertyParser<number>; static INTEGER_IN_RANGE(range: Partial<Range>): PropertyParser<number>; static get STRING_TO_INTEGER(): PropertyParser<number>; static STRING_TO_INTEGER_IN_RANGE(range: Partial<Range>): PropertyParser<number>; static get BOOLEAN(): PropertyParser<boolean>; static get STRING_TO_BOOLEAN(): PropertyParser<boolean>; static get DATE(): PropertyParser<Date>; static ARRAY<T>(parser: PropertyParser<T>): PropertyParser<T[]>; static ARRAY_IN_RANGE<T>(parser: PropertyParser<T>, range: Partial<Range>): PropertyParser<T[]>; static ENUM<T extends EnumAllowedGenericType>(enumType: EnumType<T>): PropertyParser<T>; static DTO<T>(dtoClass: ClassType<T>): PropertyParser<T>; }