import { IsEmail, IsIn, IsOptional, IsString, MaxLength, MinLength, ValidateIf } from 'class-validator' // Patch a workspace member's directory profile + in-tenant role. Every field is // optional — the drawer saves contact info and role independently, so a request // may carry just one section's worth. Empty strings are allowed (and clear the // field) for the free-text fields; alternativeEmail must be a valid email when // non-empty. export class UpdateTenantMemberDto { @IsOptional() @IsString() @MinLength(1) @MaxLength(120) name?: string @IsOptional() @IsString() @MaxLength(80) firstName?: string @IsOptional() @IsString() @MaxLength(80) lastName?: string @IsOptional() @IsString() @MaxLength(40) phone?: string // '' clears it; any other value must look like an email. @IsOptional() @ValidateIf((o) => o.alternativeEmail !== '') @IsEmail() @MaxLength(200) alternativeEmail?: string // In-tenant role only. Owner is intentionally excluded — ownership transfer // is a separate, guarded flow; this section never promotes to / demotes from // owner. @IsOptional() @IsIn(['admin', 'member']) role?: 'admin' | 'member' }