forked from Shared/esg
93 lines
1.7 KiB
TypeScript
93 lines
1.7 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import {
|
|
ArrayUnique,
|
|
IsArray,
|
|
IsBoolean,
|
|
IsEmail,
|
|
IsEnum,
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString,
|
|
Min,
|
|
MinLength,
|
|
} from 'class-validator';
|
|
import { ClientType } from '../../common/enums/client-type.enum';
|
|
import { Role } from '../../common/enums/role.enum';
|
|
import { InquiryType } from '../../common/enums/inquiry-type.enum';
|
|
|
|
export class CreateUserDto {
|
|
@ApiProperty()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
fullName!: string;
|
|
|
|
@ApiProperty()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
username!: string;
|
|
|
|
@ApiProperty()
|
|
@IsEmail()
|
|
email!: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
mobile?: string;
|
|
|
|
@ApiProperty({ minLength: 8 })
|
|
@IsString()
|
|
@MinLength(8)
|
|
password!: string;
|
|
|
|
@ApiProperty({ enum: Role, default: Role.USER })
|
|
@IsEnum(Role)
|
|
role!: Role;
|
|
|
|
@ApiProperty({ enum: ClientType, default: ClientType.EXTERNAL })
|
|
@IsEnum(ClientType)
|
|
clientType!: ClientType;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
appName?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
clientName?: string;
|
|
|
|
@ApiPropertyOptional({ default: true })
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isActive?: boolean;
|
|
|
|
@ApiPropertyOptional({
|
|
type: [String],
|
|
example: [InquiryType.PERSON, InquiryType.POSTAL_CODE],
|
|
})
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ArrayUnique()
|
|
@IsString({ each: true })
|
|
allowedInquiries?: string[];
|
|
|
|
@ApiPropertyOptional({ default: 60 })
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(1)
|
|
requestLimitPerMinute?: number;
|
|
|
|
@ApiPropertyOptional({ default: 10000 })
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(1)
|
|
requestLimitPerDay?: number;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
metadata?: Record<string, unknown>;
|
|
}
|