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

// Create an email alias `localPart@domain` that delivers to an existing mailbox
// user (the destination). Both must belong to the tenant.
export class CreateAliasDto {
  @IsString()
  @MaxLength(64)
  @Matches(/^[a-zA-Z0-9._-]+$/, { message: 'alias prefix may only contain letters, numbers, dots, hyphens and underscores' })
  localPart!: string

  @IsString()
  domain!: string

  // The destination mailbox user (our User _id); the alias is added to their account.
  @IsMongoId()
  destinationUserId!: string
}
