import { typeParser } from '@lib/utils/type-parser';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Expose, Transform } from 'class-transformer';
import { IsIn, IsInt, IsOptional, IsString } from 'class-validator';

export class Card {
  @Expose()
  @ApiProperty({ description: '카드id' })
  @Transform(({ value }) => typeParser.int(value))
  @IsInt()
  crdId!: number;

  @Expose()
  @ApiProperty({ description: '빌링키' })
  @IsString()
  crdBillingKey!: string;

  @Expose()
  @ApiProperty({ description: '카드명', example: '농협카드' })
  @IsString()
  crdName!: string;

  @Expose()
  @ApiProperty({ description: '카드타입(신용|체크)', example: '체크카드' })
  @IsString()
  crdCardType!: string;

  @Expose()
  @ApiProperty({ description: '카드번호' })
  @IsString()
  crdNumber!: string;

  @Expose()
  @ApiProperty({ description: '대표카드여부(1:대표카드, 0: 일반카드)' })
  @IsIn([0, 1])
  crdMain!: number;

  @Expose()
  @ApiPropertyOptional({ description: '카드수정일시' })
  @IsString()
  @IsOptional()
  crdUpdatedAt?: string;

  @Expose()
  @ApiProperty({ description: '카드생성일시' })
  @IsString()
  crdCreatedAt!: string;
}
