7.6.4 • Published 4 years ago

nestjs-validators v7.6.4

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Nest.js validators

Provides Nest common validators.

Installation

$ npm i nestjs-validators

Usage

Blank string validator

Checks if the string is not empty or blank, like in ' '.

export class AddressDTO {
  @IsNotBlank()
  public city: string;
  
  ...
}

No spaces validator

Checks if the string has no spaces, like in 'a b'.

export class CreateUserRequestDTO {
  @IsNoSpaces()
  public password: string;
  
  ...
}

Different than property validator

Checks if a object property is different than another one.

export class ChangePasswordRequestDTO {
  @IsNotBlank()
  public oldPassword: string;

  @IsDifferentThanProperty('oldPassword')
  public newPassword: string;
}