class CreateUserDTO extends DTO({
schema: z.object({
first: z.string().min(2).max(100),
last: z.string().min(2).max(100),
email: z.email(),
})
}) {
get fullName() {
const { first, last } = this.getData();
return `${first} ${last}`;
}
}
const dto = new CreateUserDTO({
first: 'John',
last: 'Doe',
email: 'john.doe@example.com',
});
console.log(dto.getData());
console.log(dto.fullName);
Defines an anonymous base DTO class for extension by your own DTO, which accepts and applies an input Zod schema.