export class CreateCouponSchema {
@IsOptional()
@IsString()
name: string;
@ValidateIf(obj => !obj.percent_off)
@IsNotEmpty()
@IsNumber()
amount_off: number;
@ValidateIf(obj => !obj.amount_off)
@IsNotEmpty()
@IsNumber()
@Min(0)
@Max(100)
percent_off: number;
}
I would like to have a validation schema that if amount_off is passed/defined then percent_off must not be passed. And viceversa. Any advice on how to accomplish this?