-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
New option in PhoneNumberValidator to enforce exact number of digits #7252
Conversation
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.
desktop/src/main/java/bisq/desktop/util/validation/PhoneNumberValidator.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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; |
There was a problem hiding this comment.
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.
desktop/src/main/java/bisq/desktop/util/validation/PhoneNumberValidator.java
Outdated
Show resolved
Hide resolved
desktop/src/main/java/bisq/desktop/util/validation/PhoneNumberValidator.java
Outdated
Show resolved
Hide resolved
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]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
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.