import { ApiProperty } from '@nestjs/swagger';
import { IsIn, IsNotEmpty, IsOptional, Validate } from 'class-validator';
import { IsNotExist } from 'src/utils/validators/is-not-exists.validator';
import { CarType } from '../entities/car.entity';

export class UpdateCarDto {
  @ApiProperty()
  @IsNotEmpty()
  id: number;

  @ApiProperty({ required: false })
  @IsOptional()
  @Validate(IsNotExist, ['CarEntity'], {
    message: 'با این پلاک، قبلا یک خودرو، ثبت شده است',
  })
  number?: string;

  @ApiProperty({ required: false })
  @IsOptional()
  vinCode?: string;

  @ApiProperty({ required: false })
  @IsOptional()
  engineCode?: string;

  @ApiProperty({ required: false })
  @IsOptional()
  makerBrandId?: number;

  @ApiProperty({ required: false, enum: CarType })
  @IsOptional()
  @IsIn(Object.values(CarType))
  type?: CarType;

  @ApiProperty({ required: false })
  @IsOptional()
  makeYear?: string;

  @ApiProperty({ required: false })
  @IsOptional()
  insuranceCarModel?: string;
}
