update: remove birthday and national code

This commit is contained in:
mahyargdz
2025-08-02 09:57:16 +03:30
parent 1e21988d9d
commit 9262c5b569
5 changed files with 52 additions and 22 deletions
+13 -11
View File
@@ -1,7 +1,7 @@
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsMobilePhone, IsNotEmpty, IsNumberString, IsOptional, IsString, Length, MinLength } from "class-validator";
import { IsNationalCode } from "../../../common/decorators/is-national-code.decorator";
// import { IsNationalCode } from "../../../common/decorators/is-national-code.decorator";
import { AuthMessage, ReferralMessage } from "../../../common/enums/message.enum";
export class CompleteRegistrationDto {
@@ -29,17 +29,19 @@ export class CompleteRegistrationDto {
@ApiProperty({ description: "Last name", example: "jamshidi" })
lastName: 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;
// @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;
@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;
// @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;
@IsNotEmpty({ message: AuthMessage.PASSWORD_NOT_EMPTY })
@IsString({ message: AuthMessage.PASSWORD_FORMAT_INVALID })
@@ -111,7 +111,7 @@ export class ZarinpalGateway implements IPaymentGateway {
// If we have error response data from Zarinpal, extract it
if (err.response?.data) {
const errorData = err.response.data as any;
const errorData = err.response.data as ZarinPalPGVerifyData;
this.logger.error(`Zarinpal error response:`, errorData);
// Return the Zarinpal error response if it has the expected structure
@@ -145,7 +145,7 @@ export class ZarinpalGateway implements IPaymentGateway {
} catch (error) {
// If it's a Zarinpal error response, extract the error code and return it
if (error && typeof error === "object" && "errors" in error) {
const zarinpalError = error as any;
const zarinpalError = error as ZarinPalPGVerifyData;
const firstError = zarinpalError.errors[0];
this.logger.warn(`Zarinpal verification error - Code: ${firstError.code}, Message: ${firstError.message}`);
+16 -3
View File
@@ -1,12 +1,13 @@
import { ApiProperty, PickType } from "@nestjs/swagger";
import { IsEnum, IsInt, IsNotEmpty, IsNumberString, IsString } from "class-validator";
import { IsEnum, IsInt, IsNotEmpty, IsNumberString, IsString, Length } from "class-validator";
import { FinancialMessage } from "../../../common/enums/message.enum";
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", "birthDate", "nationalCode", "phone"]) {
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 })
@@ -22,6 +23,18 @@ export class CreateRealUserDto extends PickType(CompleteRegistrationDto, ["first
@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 })
+19 -4
View File
@@ -1,10 +1,11 @@
import { ApiPropertyOptional, PartialType, PickType } from "@nestjs/swagger";
import { IsNotEmpty, IsOptional, IsString, IsUrl, Length } from "class-validator";
import { ApiProperty, ApiPropertyOptional, PartialType, PickType } from "@nestjs/swagger";
import { IsNotEmpty, IsNumberString, IsOptional, IsString, IsUrl, Length } from "class-validator";
import { UserMessage } from "../../../common/enums/message.enum";
import { IsNationalCode } from "../../../common/decorators/is-national-code.decorator";
import { AuthMessage, UserMessage } from "../../../common/enums/message.enum";
import { CompleteRegistrationDto } from "../../auth/DTO/complete-register.dto";
export class UpdateProfileDto extends PartialType(PickType(CompleteRegistrationDto, ["firstName", "lastName", "birthDate"] as const)) {
export class UpdateProfileDto extends PartialType(PickType(CompleteRegistrationDto, ["firstName", "lastName"] as const)) {
@IsOptional()
@IsNotEmpty({ message: UserMessage.USERNAME_NOT_EMPTY })
@Length(3, 50, { message: UserMessage.USERNAME_SHOULD_BE_BETWEEN_3_AND_50 })
@@ -12,6 +13,20 @@ export class UpdateProfileDto extends PartialType(PickType(CompleteRegistrationD
@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 })
+2 -2
View File
@@ -244,8 +244,8 @@ export class UsersService {
const existPhone = await queryRunner.manager.findOneBy(User, { phone: registerDto.phone });
if (existPhone) throw new BadRequestException(UserMessage.PHONE_EXIST);
const existUser = await queryRunner.manager.findOneBy(User, { nationalCode: registerDto.nationalCode });
if (existUser) throw new BadRequestException(UserMessage.NATIONAL_CODE_EXIST);
// const existUser = await queryRunner.manager.findOneBy(User, { nationalCode: registerDto.nationalCode });
// if (existUser) throw new BadRequestException(UserMessage.NATIONAL_CODE_EXIST);
const userName = slugify(`${registerDto.firstName} ${Date.now().toString().slice(-5)}`, { lower: true, trim: true });