Create own decorator @IsNotEmpty() which run @IsNotEmpty()
only in some conditions, some check to what classe is ttached
Some thing like
import { IsNotEmpty as LibraryIsNotEmpty } from '...';
const IsNotEmpty = (target) => {
if (some condition may be some check on target) {
return LibraryIsNotEmpty(target) // call original decorator
}
}
class User {
@IsNotEmpty() // custom decorator
username: string;
}
I don't need IsNotEmpty decorator when updating
From Nestjs for example
By default, all of these fields are required. To create a type with the same fields, but with each one optional, use PartialType() passing the class reference (CreateCatDto) as an argument:
export class UpdateCatDto extends PartialType(CreateCatDto) {}