Hi people im newer with Nest JS and i trying to add dto validator but for example when i tried to add isNotEmpty or Max compiler show me this error:
Unable to resolve signature of property decorator when called as an expression. This expression is not callable.
DTO:
import { Transform, Type } from 'class-transformer';
import { IsInt, isNotEmpty } from 'class-validator';
export class MessagesQueryDTO {
@isNotEmpty()
@IsInt()
@Type(() => Number)
readonly limit: number;
@isNotEmpty()
@Type(() => Number)
@IsInt()
readonly skip: number;
}
My config.json
{
"exclude": ["**/*spec.ts"],
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"esModuleInterop": true,
}
}
The isNotEmpty decorator should be IsNotEmpty with the first letter in uppercase.
To expand on Juan's answer, isNotEmpty
is the internally used check from class-valdiator
and can be used as a direct method. IsNotEmtpy
(notice the capitalization) is the decorator, and should be used with @
to denote it as a decorator.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.