bookish-potato-dto
Version:
A TypeScript DTO (Data Transfer Object) parsing and validation library. Define a schema once — get runtime validation and a fully inferred TypeScript type for free.
25 lines (24 loc) • 1.41 kB
TypeScript
import { NumberRange, PropertyData, PropertyParserStrictDataTypes, StringLength } from '../types';
import { ClassType, PrimitiveMap } from '../_types';
interface ArrayLength {
readonly minLength?: number;
readonly maxLength?: number;
}
interface PropertyDecoratorArrayData<T extends keyof PrimitiveMap> extends PropertyData<PrimitiveMap[T][]>, PropertyParserStrictDataTypes, ArrayLength {
readonly stringsLength?: T extends 'string' ? StringLength : never;
readonly numbersRange?: T extends 'number' ? NumberRange : never;
}
/**
* @deprecated Use `field.array()` inside `defineDto()` instead.
* The decorator API will be removed in the next major version (v2).
* @see https://github.com/andrei-trukhin/bookish-potato-dto-issues/blob/main/MIGRATION.md
*/
export declare function ArrayProperty<T extends keyof PrimitiveMap>(ofPrimitive: T, data?: PropertyDecoratorArrayData<T>): (target: any, propertyKey: string) => void;
type PropertyDecoratorArrayDtoData<T> = PropertyData<T[]> & ArrayLength;
/**
* @deprecated Use `field.arrayDto()` inside `defineDto()` instead.
* The decorator API will be removed in the next major version (v2).
* @see https://github.com/andrei-trukhin/bookish-potato-dto-issues/blob/main/MIGRATION.md
*/
export declare function ArrayDtoProperty<T>(ofDto: ClassType<T>, data?: PropertyDecoratorArrayDtoData<T>): (target: any, propertyKey: string) => void;
export {};