import { IsIn, IsString, IsUUID, MaxLength, ValidateIf } from 'class-validator';
import type { CashHolderType } from '../../../entities/cash-held-movement.entity';

/** Holder of the cash: own staff (name) or a supplier's driver. */
export class CashHolderDto {
  @IsIn(['OWN', 'SUPPLIER'])
  holder_type: CashHolderType;

  @ValidateIf((o: CashHolderDto) => o.holder_type === 'OWN')
  @IsString()
  @MaxLength(255)
  collector_name?: string;

  @ValidateIf((o: CashHolderDto) => o.holder_type === 'SUPPLIER')
  @IsUUID()
  supplier_id?: string;

  @ValidateIf((o: CashHolderDto) => o.holder_type === 'SUPPLIER')
  @IsUUID()
  driver_id?: string;
}
