-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7252 from cparke2/phone-number-validator-required…
…-length-option New option in PhoneNumberValidator to enforce exact number of digits
- Loading branch information
Showing
19 changed files
with
155 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
desktop/src/main/java/bisq/desktop/util/validation/PhoneNumberRequiredLengths.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package bisq.desktop.util.validation; | ||
|
||
import java.util.Map; | ||
|
||
import static java.util.Map.entry; | ||
|
||
final class PhoneNumberRequiredLengths { | ||
/** | ||
* Immutable mapping of ISO 3166 alpha-2 country code to the required length of the phone number (in digits, exluding country code prefix). | ||
* | ||
* Used by PhoneNumberValidator.java | ||
* If an entry is not present in the map, the requiredLength option will not be used in the validation. | ||
*/ | ||
private final static Map<String, Integer> NUMBER_LENGTH_MAP = Map.ofEntries( | ||
entry("AG", 7 ), // CountryCode: "1-268" | ||
entry("AI", 7 ), // CountryCode: "1-264" | ||
entry("AS", 7 ), // CountryCode: "1-684" | ||
entry("BB", 7 ), // CountryCode: "1-246", | ||
entry("BM", 7 ), // CountryCode: "1-441" | ||
entry("BS", 7 ), // CountryCode: "1-242" | ||
entry("CA", 10), // CountryCode: "1" | ||
entry("DM", 7 ), // CountryCode: "1-767" | ||
entry("DO", 10), // CountryCode: "1" (DO has three area codes 809,829,849; let user define hers) | ||
entry("GD", 7 ), // CountryCode: "1-473" | ||
entry("GU", 7 ), // CountryCode: "1-671" | ||
entry("JM", 7 ), // CountryCode: "1-876" | ||
entry("KN", 7 ), // CountryCode: "1-869" | ||
entry("KY", 7 ), // CountryCode: "1-345" | ||
entry("KZ", 10), // CountryCode: "7" | ||
entry("LC", 7 ), // CountryCode: "1-758" | ||
entry("MP", 7 ), // CountryCode: "1-670" | ||
entry("MS", 7 ), // CountryCode: "1-664" | ||
entry("PR", 10), // CountryCode: "1" | ||
entry("RU", 10), // CountryCode: "7" | ||
entry("SX", 7 ), // CountryCode: "1-721" | ||
entry("TC", 7 ), // CountryCode: "1-649" | ||
entry("TT", 7 ), // CountryCode: "1-868" | ||
entry("US", 10), // CountryCode: "1" | ||
entry("VC", 7 ), // CountryCode: "1-784" | ||
entry("VG", 7 ), // CountryCode: "1-284" | ||
entry("VI", 7 ) // CountryCode: "1-340" | ||
); | ||
|
||
static Integer getRequiredLength(String isoCountryCode) { | ||
return NUMBER_LENGTH_MAP.get(isoCountryCode); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.