import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"; import { Type } from "class-transformer"; import { IsEnum, IsNotEmpty, IsObject, IsOptional, IsString, ValidateNested, } from "class-validator"; /** The contact channel being changed on the caller's own account. */ export enum ContactChannel { Email = "email", Phone = "phone", } export class SendContactOtpDto { @ApiProperty({ enum: ContactChannel }) @IsEnum(ContactChannel) channel!: ContactChannel; @ApiProperty({ description: "The NEW email or phone to verify. The code is sent here, not to the " + "address currently on the account — that is what proves the caller " + "controls the number/inbox they are moving to.", example: "+251911223344", }) @IsString() @IsNotEmpty() value!: string; } export class UpdateContactDto extends SendContactOtpDto { @ApiProperty({ description: "The 6-digit code sent to the new value" }) @IsString() @IsNotEmpty() otp!: string; } export class AccountNameDto { @ApiProperty({ description: "Amharic name", example: "አበበ በቀለ" }) @IsString() @IsNotEmpty() am!: string; @ApiPropertyOptional({ description: "English name", example: "Abebe Bekele" }) @IsOptional() @IsString() en?: string; } export class UpdateAccountNameDto { @ApiProperty({ type: AccountNameDto }) @IsObject() @ValidateNested() @Type(() => AccountNameDto) name!: AccountNameDto; }