79160032

Date: 2024-11-05 17:04:39
Score: 1
Natty:
Report link

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) {}

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @IsNotEmpty
  • Low reputation (1):
Posted by: user27524548