import { IsString, IsOptional, IsNumber, IsBoolean, IsDateString, IsJSON, Matches, Min } from 'class-validator';

export class CreateInviteCodeDto {
  @IsString()
  @Matches(/^[A-Z0-9\-]+$/, { message: 'Code must contain only uppercase letters, numbers, and hyphens' })
  code: string;

  @IsOptional()
  @IsNumber()
  @Min(1)
  maxUses?: number;

  @IsOptional()
  @IsDateString()
  expiresAt?: string;

  @IsOptional()
  @IsString()
  description?: string;

  @IsOptional()
  @IsJSON()
  metadata?: any;
}

export class UpdateInviteCodeDto {
  @IsOptional()
  @IsString()
  @Matches(/^[A-Z0-9\-]+$/, { message: 'Code must contain only uppercase letters, numbers, and hyphens' })
  code?: string;

  @IsOptional()
  @IsNumber()
  @Min(1)
  maxUses?: number;

  @IsOptional()
  @IsDateString()
  expiresAt?: string;

  @IsOptional()
  @IsBoolean()
  isActive?: boolean;

  @IsOptional()
  @IsString()
  description?: string;

  @IsOptional()
  @IsJSON()
  metadata?: any;
}

export class UseInviteCodeDto {
  @IsString()
  code: string;
}