I am trying to validate if an object passed is of a certain type.
Country object
class Country {
code : string;
name: string;
}
Validation code
@IsNotEmpty()
@IsNotEmptyObject()
@IsObject()
@ValidateNested()
@Type(() => Country)
country: Country;
@Type is imported from class-transformer
This is the answer which is found in many of the questions on stack overflow. eg : Class-validator - validate array of objects . It does not work for me. This is for a single object and not an array of objects.