I am using validateIf() to check if the paymentService is equal to some enum value defined in my code. But it does not validate and throws an error .
@ApiProperty({ required: true })
@IsNotEmpty()
@IsEnum(PAYMENT_SERVICE,{
message:`Payment Service must be one of the valid values ${Object.values(PAYMENT_SERVICE)}`
})
paymentService: PAYMENT_SERVICE
@ApiProperty({ required: true })
@IsNotEmpty()
@IsInt()
@Transform(({ value }) => parseInt(value))
amount: number
@ApiProperty({ required: false })
@ValidateIf((object) => object.paymentService == PAYMENT_SERVICE.STRIPE)
@IsString()
@IsOptional()
currency: string
@ApiProperty({ required: true })
@IsNotEmpty()
@IsInt()
@Transform(({ value }) => parseInt(value))
qurandaziId: number
}
export enum PAYMENT_SERVICE {
STRIPE = 'STRIPE',
JAZZCASH = 'JAZZCASH',
}