Skip to content

fix: @IsPhoneNumber decorator does not match E.164 formatΒ #417

Open
@ihorTymofieiev

Description

@ihorTymofieiev

Description

Hi, I use the class-validator library to validate request data on a Node.js app. I have problems with validating phone numbers with intl. prefix (use 'ZZ' as a region)!

Example

class PhoneNumberWithIssue {
  @IsNotEmpty({ message: 'ERROR_EMPTY_PHONE_NUMBER_FIELD' })
  @IsPhoneNumber('ZZ', { message: 'ERROR_INVALID_PHONE_NUMBER' })
  phoneNumber!: string;
}

const invalidPhoneNumber = new PhoneNumberWithIssue();
invalidPhoneNumber.phoneNumber = "+380981111111++++++++++=====++++=+";
validate(invalidPhoneNumber).then(errors => {
    if (errors.length > 0) {
        console.log("validation failed. errors: ", errors);
    } else {
        console.log("validation succeed"); // Validation is succeeded, but the phone number is not valid!
    }
});

Dependencies

  • "class-validator": "^0.10.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: fixedIssues with merged PRs, but not released yet.type: fixIssues describing a broken feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions