UNPKG

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.

19 lines (18 loc) 566 B
import { SchemaMap, DtoDefinition } from './dto-definition.type'; /** * Creates a DtoDefinition from a schema map of field descriptors. * The returned object's `.fields` property can be spread to compose or extend DTOs. * * @example * const PersonDto = defineDto({ * name: field.string(), * age: field.integer(), * }); * * // Extend via spread: * const EmployeeDto = defineDto({ * ...PersonDto.fields, * position: field.string(), * }); */ export declare function defineDto<TSchema extends SchemaMap>(schema: TSchema): DtoDefinition<TSchema>;