I have two APIs, one has rest client that makes requests to the other and I would like to validate the api error it receives.
The api error signature is (in typescript):
class ApiError {
error?: string;
message: string | string[];
statusCode: number;
}
Now what I have trouble validating is the message, it is a union type of string and array of string. I want to know if there is some way to validate it using the @nestjs/class-validator library. Something like:
class ExternalApiErrorDto {
@IsString()
@IsOptional()
error?: string;
message: string | string[];
@IsPositive()
statusCode: number;
}