import { MaxLength, IsNotEmpty, IsEmail, IsString, isString, IsArray, IsOptional, Matches } from 'class-validator'
import { Role } from '../../model/role.enum'

export class UserCreateDto {
    @IsString()
    @MaxLength(30)
    readonly name: string

    @IsString()
    @MaxLength(40)
    readonly username: string

    @IsString()
    @IsOptional()
    readonly avatar?: string

    @IsEmail()
    @IsString()
    @IsOptional()
    readonly email?: string

    @IsString()
    @Matches(/^1[3-9]\d{9}$/, { message: '手机号格式不正确' })
    readonly phone: string

    @IsNotEmpty()
    @IsString()
    @MaxLength(60)
    @IsOptional()
    password?: string

    @IsOptional()
    apiUserId?: number

    @IsArray()
    readonly roles: Role[]

    @IsOptional()
    orgId?: number
}
