class-validator icon indicating copy to clipboard operation
class-validator copied to clipboard

question: Can we apply validation on entire class? Instead per property.

Open lockHrt opened this issue 3 years ago • 0 comments

Say we have a class like this.

class User{
  id: number

  @IsOptional()
  firstName: string

  @IsOptional()
  lastName: string
}

Do we have a way to apply a validation as default on every property of the class? So above class could look like:

@IsOptional()
class User{
  @IsNotEmpty()
  id: number

  firstName: string
  lastName: string
}

lockHrt avatar May 28 '22 12:05 lockHrt