【发布时间】:2021-01-21 06:37:51
【问题描述】:
我有几个 DTO 供用户使用
第一:
export class UserProfileContactDto {
@ApiProperty()
@IsNotEmpty()
@IsEmail()
readonly email: string;
@ApiProperty()
@IsNotEmpty()
@IsPhoneNumber('ua')
readonly phone: string;
}
第二:
export class UserProfileDataDto {
@ApiProperty()
@IsNotEmpty()
@IsString()
readonly name: string;
@ApiProperty({ required: false })
@IsString()
readonly lastname: string;
@ApiProperty()
@IsNotEmpty()
@IsEnum(userGenderEnum)
readonly gender: userGenderEnum;
}
我想基于这些 DTO 获得第三个 DTO:
export class UserCreateDto extends UserProfileDataDto, UserProfileContactDto{
@ApiProperty()
@IsNotEmpty()
@IsString()
@Matches(/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/, {
message: 'password too weak',
})
readonly password: string;
}
但是我不能对多个类使用扩展,并且接口对我不起作用,因为我正在使用类验证器库。
你怎么能解决我的问题?
【问题讨论】:
标签: angularjs typescript nestjs dto