Files
CRM_Montzar/apps/api/src/users/dto.ts
T

49 lines
902 B
TypeScript
Raw Normal View History

import { Type } from 'class-transformer';
import {
IsIn,
IsNumber,
IsString,
Matches,
Max,
MaxLength,
Min,
MinLength,
} from 'class-validator';
const INVITE_ROLES = ['admin', 'sales', 'support'] as const;
const ALL_ROLES = ['owner', 'admin', 'sales', 'support'] as const;
export class InviteUserDto {
@IsString()
@Matches(/^09\d{9}$|^\+98\d{10}$|^98\d{10}$|^9\d{9}$/, {
message: 'شماره موبایل معتبر نیست',
})
mobile!: string;
@IsString()
@MinLength(2)
@MaxLength(120)
fullName!: string;
@IsString()
@MinLength(8)
@MaxLength(72)
password!: string;
@IsIn(INVITE_ROLES)
role!: (typeof INVITE_ROLES)[number];
}
export class UpdateUserRoleDto {
@IsIn(ALL_ROLES)
role!: (typeof ALL_ROLES)[number];
}
export class UpdateUserCommissionDto {
@Type(() => Number)
@IsNumber()
@Min(0)
@Max(100)
commissionPercent!: number;
}