import { IsNumber, IsOptional, IsString, Max, Min, MinLength } from "class-validator";

export class ProviderDto {
  @IsString() @MinLength(1) name!: string;
}
export class UpdateProviderDto {
  @IsOptional() @IsString() @MinLength(1) name?: string;
}

// `taxRate` is the IVA fraction for this line of business (0.08 = 8%), the
// legacy one-row IMPUESTOS / IMPUESTOS_AUTOS tables made editable. Bounded at
// 1 because a rate is a fraction, not a percentage: 8 entered here would tax a
// $600 premium $4,800, and the mistake is easy to make.
export class PolicyTypeDto {
  @IsString() @MinLength(1) name!: string;
  @IsOptional() @IsString() shortDescription?: string;
  @IsOptional() @IsNumber() @Min(0) @Max(1) taxRate?: number;
}
export class UpdatePolicyTypeDto {
  @IsOptional() @IsString() @MinLength(1) name?: string;
  @IsOptional() @IsString() shortDescription?: string;
  @IsOptional() @IsNumber() @Min(0) @Max(1) taxRate?: number;
}

export class AdjusterDto {
  @IsOptional() @IsString() company?: string;
  @IsOptional() @IsString() city?: string;
  @IsOptional() @IsString() name?: string;
  @IsOptional() @IsString() phone?: string;
  @IsOptional() @IsString() beeper?: string;
}
export class UpdateAdjusterDto extends AdjusterDto {}
