93 lines
3.7 KiB
TypeScript
Executable File
93 lines
3.7 KiB
TypeScript
Executable File
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
import { IsEmail, IsMobilePhone, IsNotEmpty, IsNumberString, IsOptional, IsString, IsUrl, Length, MinLength } from "class-validator";
|
|
|
|
import { AuthMessage, FinancialMessage, UserMessage } from "../../../common/enums/message.enum";
|
|
|
|
export class CreateCustomerDto {
|
|
@IsNotEmpty({ message: AuthMessage.PHONE_NOT_EMPTY })
|
|
@IsMobilePhone("fa-IR", {}, { message: AuthMessage.INVALID_PHONE_FORMAT })
|
|
@Length(11, 11, { message: AuthMessage.PHONE_SHOULD_BE_11_DIGIT })
|
|
@ApiProperty({ description: "phone number", default: "09123456789" })
|
|
phone: string;
|
|
|
|
@IsNotEmpty({ message: AuthMessage.FIRST_NAME_NOT_EMPTY })
|
|
@IsString({ message: AuthMessage.FIRST_NAME_NOT_EMPTY })
|
|
@Length(2, 50, { message: AuthMessage.FIRST_NAME_SHOULD_BE_BETWEEN_2_AND_50 })
|
|
@ApiProperty({ description: "First name", example: "mahyar" })
|
|
firstName: string;
|
|
|
|
@IsNotEmpty({ message: AuthMessage.LAST_NAME_NOT_EMPTY })
|
|
@IsString({ message: AuthMessage.LAST_NAME_NOT_EMPTY })
|
|
@Length(2, 50, { message: AuthMessage.LAST_NAME_SHOULD_BE_BETWEEN_2_AND_50 })
|
|
@ApiProperty({ description: "Last name", example: "jamshidi" })
|
|
lastName: string;
|
|
|
|
@IsNotEmpty({ message: AuthMessage.EMAIL_NOT_EMPTY })
|
|
@IsEmail({}, { message: AuthMessage.INVALID_EMAIL_FORMAT })
|
|
@ApiProperty({ description: "Email", example: "ma@gmail.com" })
|
|
email: string;
|
|
|
|
@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 })
|
|
@ApiProperty({ description: "iranian format (10 char)", example: "4569852169" })
|
|
nationalCode: string;
|
|
|
|
@IsNotEmpty({ message: AuthMessage.PASSWORD_NOT_EMPTY })
|
|
@IsString({ message: AuthMessage.PASSWORD_FORMAT_INVALID })
|
|
@ApiProperty({ description: "password", example: "12S345SS678" })
|
|
@MinLength(8, { message: AuthMessage.PASSWORD_LENGTH })
|
|
password: string;
|
|
|
|
@ApiPropertyOptional({ description: "Economic code" })
|
|
@IsOptional()
|
|
@IsString({ message: FinancialMessage.ECONOMIC_CODE_INVALID })
|
|
economicCode?: string;
|
|
|
|
@ApiPropertyOptional({ description: "Company registered name" })
|
|
@IsOptional()
|
|
@IsString({ message: FinancialMessage.ECONOMIC_CODE_INVALID })
|
|
companyRegisteredName?: string;
|
|
|
|
@ApiPropertyOptional({ description: "Registration ID" })
|
|
@IsOptional()
|
|
@IsString({ message: FinancialMessage.REGISTRATION_ID_INVALID })
|
|
registrationId?: string;
|
|
|
|
@ApiPropertyOptional({ description: "national Id" })
|
|
@IsOptional()
|
|
@IsString({ message: FinancialMessage.NATIONAL_ID_INVALID })
|
|
nationalId?: string;
|
|
|
|
@ApiPropertyOptional({ description: "number" })
|
|
@IsOptional()
|
|
@IsString({ message: FinancialMessage.FIXED_PHONE_INVALID })
|
|
number?: string;
|
|
|
|
@ApiPropertyOptional({ description: "postalCode" })
|
|
@IsOptional()
|
|
@IsString({ message: FinancialMessage.NATIONAL_ID_INVALID })
|
|
postalCode?: string;
|
|
|
|
@ApiPropertyOptional({ description: "address" })
|
|
@IsOptional()
|
|
@IsString({ message: FinancialMessage.NATIONAL_ID_INVALID })
|
|
address?: string;
|
|
|
|
@ApiPropertyOptional({ description: "City id", example: "1" })
|
|
@IsOptional()
|
|
@IsNotEmpty({ message: FinancialMessage.CITY_ID_REQUIRED })
|
|
cityId: string;
|
|
|
|
@IsOptional()
|
|
@IsNotEmpty({ message: UserMessage.PROFILE_PIC_REQUIRED })
|
|
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: UserMessage.PROFILE_PIC_URL })
|
|
@ApiPropertyOptional({ description: "Profile picture", example: "https://www.google.com" })
|
|
profilePic: string;
|
|
}
|