import { ApiProperty } from "@nestjs/swagger";
import { IsEmail, IsOptional, IsString, Length, Matches } from "class-validator";

export class CreateMerchantDto {
  @ApiProperty({ example: "Acme S.A.", minLength: 2, maxLength: 120 })
  @IsString()
  @Length(2, 120)
  name!: string;

  @ApiProperty({ example: "billing@acme.com.py", format: "email" })
  @IsEmail()
  email!: string;

  @ApiProperty({
    example: "PY",
    description: "ISO 3166-1 alpha-2 en mayúsculas.",
    minLength: 2,
    maxLength: 2,
  })
  @IsString()
  @Length(2, 2, { message: "defaultCountry must be ISO 3166-1 alpha-2" })
  @Matches(/^[A-Z]{2}$/, { message: "defaultCountry must be uppercase ISO 3166-1 alpha-2" })
  defaultCountry!: string;

  @ApiProperty({
    required: false,
    example: "acme-sa",
    description: "Slug opcional. Si no se envía, se deriva de `name`.",
  })
  @IsOptional()
  @IsString()
  @Length(2, 60)
  slug?: string;
}
