How to check whether the array is empty or not using class-validator.
Given below is my structure. I want to check if cartId is empty or not.
{
"cartId": []
}
What you want is @ArrayNotEmpty()
.
You can find all built-in validators here: https://github.com/typestack/class-validator#validation-decorators
If you don't find - you can write your own validator: https://github.com/typestack/class-validator#custom-validation-classes