import { IsBoolean, IsNotEmpty, IsOptional, IsString, MaxLength, ValidateIf } from 'class-validator';
import { Trim, TrimOrNull } from '../../../common/dto/field-transforms';

/** Every field optional; the name can be changed but never cleared. */
export class UpdateServiceDto {
  @ValidateIf((o: UpdateServiceDto) => o.name !== undefined)
  @Trim()
  @IsString()
  @IsNotEmpty({ message: 'Enter the service name' })
  @MaxLength(120)
  name?: string;

  @TrimOrNull()
  @IsOptional()
  @IsString()
  @MaxLength(2000)
  description?: string | null;

  @IsOptional()
  @IsBoolean()
  isActive?: boolean;
}
