mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 16:44:54 +00:00
56 lines
2.2 KiB
TypeScript
56 lines
2.2 KiB
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
import {
|
|
IsDateString,
|
|
IsEmail,
|
|
IsEnum,
|
|
IsNotEmpty,
|
|
IsNumberString,
|
|
IsOptional,
|
|
IsString,
|
|
IsUUID,
|
|
} from 'class-validator';
|
|
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
|
|
import { CardColors } from '~/card/enums';
|
|
import { Gender } from '~/customer/enums';
|
|
import { Relationship } from '~/junior/enums';
|
|
export class CreateJuniorRequestDto {
|
|
@ApiProperty({ example: 'John' })
|
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'customer.firstName' }) })
|
|
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'customer.firstName' }) })
|
|
firstName!: string;
|
|
|
|
@ApiProperty({ example: 'Doe' })
|
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'customer.lastName' }) })
|
|
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'customer.lastName' }) })
|
|
lastName!: string;
|
|
|
|
@ApiProperty({ enum: Gender })
|
|
@IsEnum(Gender, { message: i18n('validation.IsEnum', { path: 'general', property: 'customer.gender' }) })
|
|
gender!: Gender;
|
|
|
|
@ApiProperty({ example: '2020-01-01' })
|
|
@IsDateString({}, { message: i18n('validation.IsDateString', { path: 'general', property: 'customer.dateOfBirth' }) })
|
|
dateOfBirth!: Date;
|
|
|
|
@ApiProperty({ example: 'test@test.com' })
|
|
@IsEmail({}, { message: i18n('validation.IsEmail', { path: 'general', property: 'auth.email' }) })
|
|
email!: string;
|
|
|
|
@ApiProperty({ example: Relationship.PARENT })
|
|
@IsEnum(Relationship, { message: i18n('validation.IsEnum', { path: 'general', property: 'junior.relationship' }) })
|
|
relationship!: Relationship;
|
|
|
|
@ApiProperty({ enum: CardColors })
|
|
@IsEnum(CardColors, { message: i18n('validation.IsEnum', { path: 'general', property: 'junior.cardColor' }) })
|
|
cardColor!: CardColors;
|
|
|
|
@ApiProperty({ example: '1234' })
|
|
@IsNumberString({}, { message: i18n('validation.IsEnum', { path: 'general', property: 'junior.cardPin' }) })
|
|
cardPin!: string;
|
|
|
|
@ApiProperty({ example: '123e4567-e89b-12d3-a456-426614174000' })
|
|
@IsUUID('4', { message: i18n('validation.IsUUID', { path: 'general', property: 'customer.profilePictureId' }) })
|
|
@IsOptional()
|
|
profilePictureId!: string;
|
|
}
|