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

New option in PhoneNumberValidator to enforce exact number of digits #7252

Conversation

cparke2
Copy link
Contributor

@cparke2 cparke2 commented Sep 19, 2024

Until now, national phone numbers worldwide just had to be between 5-12 digits long to pass validation. However, many countries have a specific number of of digits in all their phone numbers which is very well known (EX: all USA numbers are 10 digits long). So this change adds an optional parameter to specify how many digits must be in the phone number for it to validate. Uncommited changes will also use this new capability, provided this pull request is adopted.

Until now, national phone numbers worldwide just had to be between
5-12 digits long to pass validation. However, many countries have a
specific number of of digits in all their phone numbers which is
very well known (EX: all USA numbers are 10 digits long). So this
change adds an optional parameter to specify how many digits must
be in the phone number for it to validate. Uncommited changes will
also use this new capability, provided this pull request is adopted.
Original commit omitted the new display string used by this new
feature. Additionally, added two unittests to verify the code
changes in this pull request work and do not break existing
functionality.
Copy link
Collaborator

@HenrikJannsen HenrikJannsen left a comment

Choose a reason for hiding this comment

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

See comments

* Required length of phone number (excluding country code).
*/
@Getter
private int requiredLength;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As it is optional I would suggest to use an Optional type instead.

Created new class PhoneNumberRequiredLengths.java with a Map lookup for the
requiredlength of phone numbers in select countries that are well-known to
have uniform fixed-length phone number throughout. Country codes missing
will continue to use just the previous length-range algorithms.  Lookup
into this Map is integrated into PhoneNumberValidator.java, no longer
needed an overloaded constructor to provide this functionality.
Created new class PhoneNumberRequiredLengths.java with a Map lookup for the
requiredlength of phone numbers in select countries that are well-known to
have uniform fixed-length phone number throughout. Country codes missing
will continue to use just the previous length-range algorithms.  Lookup
into this Map is integrated into PhoneNumberValidator.java, no longer
needed an overloaded constructor to provide this functionality.
[New .java file was accidentally omitted from previous commit]
Copy link
Collaborator

@HenrikJannsen HenrikJannsen left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Collaborator

@HenrikJannsen HenrikJannsen left a comment

Choose a reason for hiding this comment

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

utACK

@HenrikJannsen HenrikJannsen merged commit f37344b into bisq-network:master Sep 27, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants