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

// Add an alias address (localPart@domain) that delivers to the member's
// mailbox. The domain must be one of this tenant's provisioned mail domains.
export class AddAliasDto {
  @IsString()
  @MaxLength(64)
  @Matches(/^[a-zA-Z0-9._-]+$/, {
    message: 'alias prefix may only contain letters, numbers, dots, hyphens and underscores',
  })
  localPart!: string

  @IsString()
  @MaxLength(255)
  domain!: string
}

// Remove an alias by its full address.
export class RemoveAliasDto {
  @IsEmail()
  @MaxLength(320)
  address!: string
}
