import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsNotEmpty, IsNumber, IsOptional, IsUUID, Length, Matches, Max, Min } from 'class-validator';

export class CreatePersonaDto {
  @ApiProperty({ example: 'cd88ac6a-2b0e-41bc-afd9-24b594cb8daf' })
  @IsOptional()
  @IsUUID()
  tipo_documento_id?: string;

  @ApiProperty({ example: 'cd88ac6a-2b0e-41bc-afd9-24b594cb8daf' })
  @IsOptional()
  @IsUUID()
  pais_id?: string;

  @ApiProperty({ example: 'cd88ac6a-2b0e-41bc-afd9-24b594cb8daf' })
  @IsOptional()
  ciudad_id?: string;

  @ApiProperty({ example: 'cd88ac6a-2b0e-41bc-afd9-24b594cb8daf' })
  @IsNotEmpty({ message: 'Naturaleza es obligatoria' })
  naturaleza_id: string;

  @ApiProperty({ example: 'cd88ac6a-2b0e-41bc-afd9-24b594cb8daf' })
  @IsOptional()
  @IsUUID()
  tipo_contribuyente_id?: string;

  @ApiProperty({ example: 'Empresa S.A.' })
  @IsNotEmpty({ message: 'Razón social debe tener entre 4 y 255 caracteres' })
  @Length(4, 255, { message: 'Razón social debe tener entre 4 y 255 caracteres' })
  razon_social: string;

  @ApiProperty({ example: 'Av. Siempre Viva 123' })
  @IsOptional()
  @Length(4, 255, { message: 'Dirección debe tener entre 4 y 255 caracteres' })
  direccion?: string;

  @ApiProperty({ example: '0' })
  @IsOptional()
  // @Length(1, 6, { message: 'Número casa debe tener entre 1 y 6 dígitos' })
  nro_casa?: string;

  @ApiProperty({ example: '0981743100' })
  @IsOptional()
  @Length(10, 20, { message: 'Celular debe tener mínimo 12 y máximo 20 caracteres' })
  celular?: string;

  @ApiProperty({ example: '021123456' })
  @IsOptional()
  @Length(6, 20, { message: 'Teléfono debe tener entre 6 y 20 caracteres' })
  telefono?: string;

  @ApiProperty({ example: 'email@example.com' })
  @IsOptional()
  @IsEmail({}, { message: 'Email debe tener un formato válido' })
  @Length(3, 80, { message: 'Email debe tener entre 3 y 80 caracteres' })
  email?: string;

  @ApiProperty({ example: '12345678' })
  @IsOptional()
  @IsNotEmpty({ message: 'RUC debe tener entre 3 y 8 dígitos' })
  @Length(3, 8, { message: 'RUC debe tener entre 3 y 8 dígitos' })
  ruc?: string;

  @ApiProperty({ example: '1' })
  @IsOptional()
  @IsNumber({}, { message: 'DV debe ser un número' })
  @Min(0, { message: 'DV debe ser un número entre 0 y 9' })
  @Max(9, { message: 'DV debe ser un número entre 0 y 9' })
  dv?: number;

  @ApiProperty({ example: '12345678' })
  @IsOptional()
  @Length(1, 20, { message: 'Nro documento debe tener entre 1 y 20 caracteres' })
  nro_documento?: string;

  @ApiProperty({ example: '' })
  @IsOptional()
  @Length(9, 41, { message: 'Otro tipo documento debe tener entre 9 y 41 caracteres' })
  otro_tipo_documento?: string;

  @ApiProperty({ example: 'email@example.com' })
  @IsOptional()
  @IsEmail({}, { message: 'Email adicional debe tener un formato válido' })
  @Length(3, 80, { message: 'Email adicional debe tener entre 3 y 80 caracteres' })
  email_adicional?: string;

  @ApiProperty({ example: 'email@example.com' })
  @IsOptional()
  @IsEmail({}, { message: 'Email copia debe tener un formato válido' })
  @Length(3, 80, { message: 'Email copia debe tener entre 3 y 80 caracteres' })
  email_copia?: string;
}
