54 lines
2.4 KiB
TypeScript
Executable File
54 lines
2.4 KiB
TypeScript
Executable File
import { ApiProperty, PickType } from "@nestjs/swagger";
|
|
import { IsEnum, IsInt, IsNotEmpty, IsNumberString, IsString, Length } from "class-validator";
|
|
|
|
import { IsNationalCode } from "../../../common/decorators/is-national-code.decorator";
|
|
import { AuthMessage, FinancialMessage } from "../../../common/enums/message.enum";
|
|
import { CompleteRegistrationDto } from "../../auth/DTO/complete-register.dto";
|
|
import { GenderEnum } from "../enums/gender-type.enum";
|
|
import { NationalityEnum } from "../enums/nationality.enum";
|
|
|
|
export class CreateRealUserDto extends PickType(CompleteRegistrationDto, ["firstName", "lastName", "phone"]) {
|
|
@IsNotEmpty({ message: FinancialMessage.GENDER_TYPE_REQUIRED })
|
|
@IsEnum(GenderEnum)
|
|
@ApiProperty({ enum: GenderEnum, description: "Gender type", example: GenderEnum.MALE })
|
|
gender: GenderEnum;
|
|
|
|
@IsNotEmpty({ message: FinancialMessage.FATHER_NAME_REQUIRED })
|
|
@IsString({ message: FinancialMessage.FATHER_NAME_INVALID })
|
|
@ApiProperty({ description: "Father name" })
|
|
fatherName: string;
|
|
|
|
@IsNotEmpty({ message: FinancialMessage.NATIONALITY_REQUIRED })
|
|
@IsEnum(NationalityEnum)
|
|
@ApiProperty({ description: "Nationality" })
|
|
nationality: NationalityEnum;
|
|
|
|
@IsNotEmpty({ message: AuthMessage.BIRTH_DATE_NOT_EMPTY })
|
|
@IsString({ message: AuthMessage.BIRTH_DATE_NOT_EMPTY })
|
|
@ApiProperty({ description: "Birth date", example: "1403/01/01" })
|
|
birthDate: string;
|
|
|
|
@IsNotEmpty({ message: AuthMessage.NATIONAL_NOT_EMPTY })
|
|
@IsNumberString({ no_symbols: true }, { message: AuthMessage.NATIONAL_CODE_INCORRECT })
|
|
@Length(10, 10, { message: AuthMessage.NATIONAL_CODE_INCORRECT })
|
|
@IsNationalCode({ message: AuthMessage.NATIONAL_CODE_INVALID })
|
|
@ApiProperty({ description: "iranian format (10 char)", example: "4569852169" })
|
|
nationalCode: string;
|
|
|
|
//for address entity
|
|
@IsNotEmpty({ message: FinancialMessage.ADDRESS_REQUIRED })
|
|
@IsString({ message: FinancialMessage.ADDRESS_STRING })
|
|
@ApiProperty({ description: "Address" })
|
|
address: string;
|
|
|
|
@IsNotEmpty({ message: FinancialMessage.POSTAL_CODE_REQUIRED })
|
|
@IsNumberString({ no_symbols: true }, { message: FinancialMessage.POSTAL_CODE_NUMBER_STRING })
|
|
@ApiProperty({ description: "Postal code", example: "1234567890" })
|
|
postalCode: string;
|
|
|
|
@IsNotEmpty({ message: FinancialMessage.CITY_ID_REQUIRED })
|
|
@IsInt({ message: FinancialMessage.CITY_ID_INVALID })
|
|
@ApiProperty({ description: "City ID", example: "1" })
|
|
cityId: number;
|
|
}
|