Using conditional validation in the class-validation library and the example below, I want the validation to fail if the woodScrews property is given a value when the tool property is Tool.TapeMeasure. I wasn't really able to find anything that does that.
import { IsEnum, IsNumber, Min, ValidateIf } from 'class-validator'
export enum Tool {
Drill = 'Drill',
TapeMeasure = 'Tape Measure'
}
export class ToolBox {
@IsEnum(Tool)
public tool: Tool;
@ValidateIf(toolBox => toolBox.tool === Tool.Drill)
@IsNumber()
@Min(5)
public woodScrews?: number;
}