ES2017 NEST JS @IsEmpty Unable to resolve signature of property decorator when called as an expression.This expression is not callable. is not empty

2.6k views Asked by At

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,
  }
}
2

There are 2 answers

0
Jay McDoniel On BEST ANSWER

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.

0
Juan Rambal On

The isNotEmpty decorator should be IsNotEmpty with the first letter in uppercase.