import { ApiProperty } from "@nestjs/swagger";
import { IsEnum, IsInt, IsNotEmpty, IsString, Matches, Max, MaxLength, Min } from "class-validator";
import { TenantEntorno } from "../../control-plane/entities/tenant.entity";

export class RegisterTenantDto {
  @ApiProperty({ description: "Identificador corto y unico, ej. 'autocentro-rodriguez'" })
  @IsString()
  @IsNotEmpty()
  @MaxLength(64)
  @Matches(/^[a-z0-9-]+$/, {
    message: "codigo solo puede tener minusculas, numeros y guiones",
  })
  codigo: string;

  @ApiProperty()
  @IsString()
  @IsNotEmpty()
  @MaxLength(255)
  nombre: string;

  @ApiProperty({ enum: TenantEntorno })
  @IsEnum(TenantEntorno)
  entorno: TenantEntorno;

  @ApiProperty()
  @IsString()
  @IsNotEmpty()
  dbHost: string;

  @ApiProperty()
  @IsInt()
  @Min(1)
  @Max(65535)
  dbPort: number;

  @ApiProperty()
  @IsString()
  @IsNotEmpty()
  dbName: string;

  @ApiProperty()
  @IsString()
  @IsNotEmpty()
  dbUser: string;

  @ApiProperty()
  @IsString()
  @IsNotEmpty()
  dbPassword: string;
}
