nestjs-validators
v7.6.4
Published
Provides common Nest.js validators.
Downloads
13
Readme
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;
}