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

// Add a custom email domain to a tenant. The domain is lowercased + trimmed by
// the schema; we validate it's a plausible hostname here (no protocol, no path,
// at least one dot). Punycode/IDN is accepted as already-encoded ascii.
export class AddDomainDto {
  @IsString()
  @MaxLength(253)
  @Matches(/^(?!-)[a-z0-9-]{1,63}(?<!-)(\.(?!-)[a-z0-9-]{1,63}(?<!-))+$/i, {
    message: 'domain must be a valid hostname like acme.dk',
  })
  domain!: string
}
