forked from Yara724/api
fix: harden profile updates and localize public errors in Persian
Preserve actor and user profile fields during partial updates and validate supported personal data. Add Persian HTTP error handling, validation translations, regression tests, and audit documentation.
This commit is contained in:
@@ -1,27 +1,42 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { IsDateString } from "class-validator";
|
||||
import { ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import {
|
||||
IsDateString,
|
||||
IsIn,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
} from "class-validator";
|
||||
|
||||
export class UpdateUserProfileDtoRq {
|
||||
// @ApiProperty({})
|
||||
// mobile: string;
|
||||
@ApiProperty({
|
||||
type: "string",
|
||||
description: "Birth date of the user",
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
"Gregorian birth date (YYYY-MM-DD). Legacy packed Jalali dates are also accepted.",
|
||||
example: "1999-03-05",
|
||||
nullable: true,
|
||||
})
|
||||
@IsDateString()
|
||||
birthDay: string;
|
||||
@IsOptional()
|
||||
@IsDateString({ strict: true }, { message: "تاریخ تولد معتبر نیست." })
|
||||
birthDay?: string;
|
||||
|
||||
@ApiProperty()
|
||||
@ApiPropertyOptional({ enum: ["male", "female"] })
|
||||
@IsOptional()
|
||||
@IsIn(["male", "female"], { message: "جنسیت معتبر نیست." })
|
||||
gender?: "male" | "female";
|
||||
|
||||
@ApiProperty()
|
||||
city: string;
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
city?: string;
|
||||
|
||||
@ApiProperty()
|
||||
state: string;
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
state?: string;
|
||||
|
||||
@ApiProperty()
|
||||
address: string;
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(1000, { message: "نشانی باید حداکثر ۱۰۰۰ کاراکتر باشد." })
|
||||
address?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user