小编Nin*_*nja的帖子

作为表达式调用时无法解析属性装饰器的签名

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

}
Run Code Online (Sandbox Code Playgroud)

问题是 @isEmail() 和 @isPhoneNumber() 和 @isEmpty() 抛出相同的错误:

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) …
Run Code Online (Sandbox Code Playgroud)

typescript graphql class-validator typegraphql

12
推荐指数
2
解决办法
3万
查看次数