Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change isValidNumber to isPossibleNumber #36

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/shared/externalContraints/externalConstraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const externalConstraints = {
if (value) {
try {
const phoneNumber = phoneUtil.parse(value, config.region);
if (!phoneUtil.isValidNumber(phoneNumber)) {
if (!phoneUtil.isPossibleNumber(phoneNumber)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Validation logic changed from isValidNumber to isPossibleNumber

The change from isValidNumber to isPossibleNumber aligns with the PR objective. However, there are a few points to consider:

  1. The error message "Invalid phone number" is now less accurate. Consider updating it to "Impossible phone number" or "Phone number doesn't meet basic format requirements" to reflect the new validation logic.

  2. It would be helpful to add a comment explaining the rationale behind this change. For example:

    // Using isPossibleNumber instead of isValidNumber to allow for a wider range of valid phone numbers
    // while still catching obviously incorrect formats.
  3. Please consider the implications of this change:

    • It will allow more phone numbers to pass validation, potentially including some that are formatted correctly but not actually in use.
    • This might reduce false negatives (rejecting valid numbers) but could increase false positives (accepting invalid numbers).

Could you update the error message and add a comment explaining the change? Also, please confirm if this looser validation aligns with the project's requirements for phone number accuracy.

record.addError(key, 'Invalid phone number.');
}
} catch (error) {
Expand Down
Loading