Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve signature of property decorator when called as an expression

import { isEmail, isEmpty, isPhoneNumber, Length } from "class-validator"
import { Field, InputType } from "type-graphql";

@InputType()
export class RegisterInput {
    @Field()
    @Length(2, 15, { message: "Username Must Be At Least 2 characters" })
    username?: string;

    @Field()
    @isEmail()
    email?: string;

    @Field()
    @Length(1, 20)
    @isPhoneNumber()
    phoneNumber?: string;

    @isEmpty()
    password?: string

}

The thing is @isEmail() and @isPhoneNumber() and @isEmpty() throw the same error:

Unable to resolve signature of property decorator when called as an expression.
  This expression is not callable.
    Type 'Boolean' has no call signatures.ts(1240)

Please help me out I've been stuck with this bug the whole day

like image 475
Ninja Avatar asked Dec 10 '25 07:12

Ninja


1 Answers

You have to write those Decorators with a capital letter. TypeScript is case sensitive:

import { IsEmail, IsEmpty, IsPhoneNumber, Length } from "class-validator";

@Field()
@IsEmail()
email?: string;

@Field()
@Length(1, 20)
@IsPhoneNumber()
phoneNumber?: string;

@IsEmpty()
password?: string

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!