import { IsOptional, IsString, Matches, MaxLength } from 'class-validator'

// Provision a Stalwart mailbox for an existing member who doesn't have one yet
// (e.g. the bootstrap admin who signs in with an external email). The mailbox
// is `localPart@domain` on one of the tenant's provisioned domains; the
// member's sign-in identity is left untouched.
export class CreateMailboxDto {
  @IsString()
  @MaxLength(64)
  @Matches(/^[a-zA-Z0-9._-]+$/, {
    message: 'address prefix may only contain letters, numbers, dots, hyphens and underscores',
  })
  localPart!: string

  // Optional explicit domain (must belong to the tenant); omitted = primary.
  @IsOptional()
  @IsString()
  domain?: string
}
