Open
Description
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"