Files
canina/backend/src/admin/dto/user.dto.ts
T

100 lines
2.9 KiB
TypeScript

import {
IsNotEmpty,
IsString,
IsOptional,
IsEmail,
MinLength,
IsNumber,
IsIn,
} from "class-validator";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { ALLOWED_USER_ROLES } from "../user-role-policy";
export class CreateUserDto {
@ApiProperty({ description: "نام کاربر", example: "علی" })
@IsNotEmpty({ message: "نام الزامی است" })
@IsString()
firstName!: string;
@ApiProperty({ description: "نام خانوادگی کاربر", example: "محمدی" })
@IsNotEmpty({ message: "نام خانوادگی الزامی است" })
@IsString()
lastName!: string;
@ApiProperty({ description: "شماره موبایل", example: "09123456789" })
@IsNotEmpty({ message: "شماره موبایل الزامی است" })
@IsString()
mobile!: string;
@ApiPropertyOptional({
description: "ایمیل کاربر",
example: "ali@example.com",
})
@IsOptional()
@IsEmail({}, { message: "فرمت ایمیل نامعتبر است" })
email?: string;
@ApiPropertyOptional({ description: "رمز عبور", example: "Password123" })
@IsOptional()
@IsString()
@MinLength(6, { message: "رمز عبور باید حداقل ۶ کاراکتر باشد" })
password?: string;
@ApiPropertyOptional({ description: "نقش کاربر", example: "User_PetOwner" })
@IsOptional()
@IsString()
@IsIn(ALLOWED_USER_ROLES)
role?: string;
@ApiPropertyOptional({ description: "موجودی اولیه کیف پول", example: 0 })
@IsOptional()
@IsNumber({}, { message: "موجودی کیف پول باید عدد باشد" })
walletBalance?: number;
}
export class UpdateUserDto {
@ApiPropertyOptional({ description: "نام کاربر", example: "علی" })
@IsOptional()
@IsString()
firstName?: string;
@ApiPropertyOptional({ description: "نام خانوادگی کاربر", example: "محمدی" })
@IsOptional()
@IsString()
lastName?: string;
@ApiPropertyOptional({ description: "شماره موبایل", example: "09123456789" })
@IsOptional()
@IsString()
mobile?: string;
@ApiPropertyOptional({
description: "ایمیل کاربر",
example: "ali@example.com",
})
@IsOptional()
@IsEmail({}, { message: "فرمت ایمیل نامعتبر است" })
email?: string;
@ApiPropertyOptional({
description: "رمز عبور جدید",
example: "NewPassword123",
})
@IsOptional()
@IsString()
@MinLength(6, { message: "رمز عبور باید حداقل ۶ کاراکتر باشد" })
password?: string;
@ApiPropertyOptional({ description: "نقش کاربر", example: "User_PetOwner" })
@IsOptional()
@IsString()
@IsIn(ALLOWED_USER_ROLES)
role?: string;
@ApiPropertyOptional({ description: "موجودی کیف پول", example: 500000 })
@IsOptional()
@IsNumber({}, { message: "موجودی کیف پول باید عدد باشد" })
walletBalance?: number;
}