I have the following DTO:
export class InputDTO {
value1: string;
value2: string:
}
I want to do validation in such a way that if value1 field is a specific value(say "toy"), then value2 should not be empty. How can I achieve this?
I have the following DTO:
export class InputDTO {
value1: string;
value2: string:
}
I want to do validation in such a way that if value1 field is a specific value(say "toy"), then value2 should not be empty. How can I achieve this?
The NestJS documentation points class-validator documentation for such customization.
Conditional validation seems to suit your need : https://github.com/typestack/class-validator#conditional-validation
Something similar to this should work: