import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsString, IsNotEmpty, IsNumber, IsOptional } from 'class-validator';

/**
 * DTO used to update commission contract details.
 *
 * Both fields are optional, allowing partial updates.
 * Primarily used when modifying the contract name or its display/order sequence.
 */
export class UpdateCommissionContractDto {
  /**
   * Name of the commission contract.
   *
   * Optional field:
   * - Can be used to rename the commission contract.
   * - If omitted, the contract name remains unchanged.
   */
  @IsOptional()
  @IsString() // Must be a string when provided
  @ApiPropertyOptional()
  name?: string;

  /**
   * Order or sequence number for the contract.
   *
   * Optional field:
   * - Defines the display or processing order of contracts.
   * - Must be a numeric value if provided.
   * - Defaults to 0 if not specified.
   */
  @IsOptional()
  @IsNumber({}, { message: 'order must be a number' }) // Ensures numeric value
  @ApiPropertyOptional({ default: 0 })
  order?: number;
}
