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

const SLUG = /^[a-z0-9]([a-z0-9-]{0,38}[a-z0-9])?$/
const TZ = /^[A-Za-z]+\/[A-Za-z0-9_+-]+(\/[A-Za-z0-9_+-]+)?$/

export class CreateHostDto {
  // The workspace user to make bookable. Their mailbox, OIDC subject and display
  // name are resolved server-side from this id — the client never supplies them.
  @IsMongoId()
  userId!: string

  @IsString()
  @Matches(SLUG, { message: 'slug must be lowercase, 2-40 chars, hyphen-separated' })
  slug!: string

  @IsString()
  @MaxLength(64)
  @Matches(TZ, { message: 'timezone must be an IANA zone like Europe/Copenhagen' })
  timezone!: string
}

export class SetHostActiveDto {
  @IsBoolean()
  isActive!: boolean
}
