import { BaseDto } from 'src/core/modules/infrastructure/dto/base.dto';
import { VipCodeEntity } from '../../domain/entities/vip-code.entity';
import { IsNumber, IsObject, IsString, ValidateIf } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class VipCodeDto extends BaseDto implements VipCodeEntity {
  @ApiProperty({
    name: 'code',
    type: String,
    required: true,
    example: '0824A12',
  })
  @IsString()
  code: string;

  @ApiProperty({
    name: 'discount',
    type: Number,
    required: false,
    example: 85,
  })
  @IsNumber()
  discount: number;

  @ApiProperty({
    name: 'discount_value',
    type: Number,
    required: false,
    example: 25000,
  })
  @IsNumber()
  @ValidateIf((v) => v.discount_value)
  discount_value: number;

  @ApiProperty({
    name: 'vip_category',
    type: Object,
    required: true,
    example: {
      id: 'uuid',
    },
  })
  @IsObject()
  vip_category: VipCodeEntity;
}
