Files
dsc-api/src/modules/users/DTO/update-profile.dto.ts
T

68 lines
2.9 KiB
TypeScript
Executable File

import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsNotEmpty, IsNumberString, IsOptional, IsString, IsUrl, Length } from "class-validator";
import { IsNationalCode } from "../../../common/decorators/is-national-code.decorator";
import { AuthMessage, UserMessage } from "../../../common/enums/message.enum";
export class UpdateProfileDto {
@IsOptional()
@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;
@IsOptional()
@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;
@IsOptional()
@IsNotEmpty({ message: UserMessage.USERNAME_NOT_EMPTY })
@Length(3, 50, { message: UserMessage.USERNAME_SHOULD_BE_BETWEEN_3_AND_50 })
@IsString({ message: UserMessage.USERNAME_NOT_EMPTY })
@ApiPropertyOptional({ description: "User name", example: "mamad24" })
userName?: string;
@IsOptional()
@IsNotEmpty({ message: AuthMessage.BIRTH_DATE_NOT_EMPTY })
@IsString({ message: AuthMessage.BIRTH_DATE_NOT_EMPTY })
@ApiProperty({ description: "Birth date", example: "1403/01/01" })
birthDate?: string;
@IsOptional()
@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;
@ApiPropertyOptional({ description: "Profile picture", example: "https://www.google.com" })
@IsOptional()
@IsNotEmpty({ message: UserMessage.PROFILE_PIC_REQUIRED })
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: UserMessage.PROFILE_PIC_URL })
profilePic?: string;
@ApiPropertyOptional({ description: "User address", example: "123 Main St" })
@IsOptional()
@IsNotEmpty({ message: UserMessage.ADDRESS_REQUIRED })
@IsString({ message: UserMessage.ADDRESS_SHOULD_BE_STRING })
@Length(5, 255, { message: UserMessage.ADDRESS_LENGTH })
userAddress?: string;
@ApiPropertyOptional({ description: "Postal code", example: "1234567890" })
@IsOptional()
@IsNotEmpty({ message: UserMessage.POSTAL_CODE_REQUIRED })
@IsString({ message: UserMessage.POSTAL_CODE_SHOULD_BE_STRING })
@Length(10, 10, { message: UserMessage.POSTAL_CODE_LENGTH })
postalCode?: string;
@IsOptional()
@ApiPropertyOptional({ description: "City id" })
@IsNotEmpty({ message: UserMessage.CITY_REQUIRED })
cityId?: string;
}