'how can I use decorator for method variable inside class in nestjs?

import {isNotEmpty} from "class-validator";

export Service   {

create(createdto)
{
const {name,age} = createdto;

@isNotEmpty()
name          //using decorator to check whether name is null or 
undefined
} 
}

Since, the decorator is only useful to class methods, I cannot use it inside method variables. How can it validate the method variables?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source