[bisq-network/bisq] Validate phone numbers (#3134)

Stan notifications at github.com
Sat Aug 24 15:02:32 UTC 2019


ghubstan commented on this pull request.



> +    public ValidationResult validate(String input) {
+        normalizedPhoneNumber = null;
+        ValidationResult result = super.validate(input);
+        if (!result.isValid) {
+            return result;
+        }
+        final String trimmedInput = input.trim();
+        boolean isCountryDialingCodeExplicit = trimmedInput.startsWith("+");
+        // remove non-digit chars:  plus sign, dashes, parens, hashes, slashes and white spaces
+        String pureNumber = input.replaceAll("[\\+\\s+()\\-\\−\\#\\\\]", "");
+        boolean hasValidCallingCodePrefix = pureNumber.startsWith(normalizedCallingCode);
+        boolean isCountryCallingCodeImplicit = !isCountryDialingCodeExplicit && hasValidCallingCodePrefix;
+
+        result = validateIsNumeric(input, pureNumber)
+                .and(validateHasSufficientDigits(input, pureNumber))
+                .and(validateIsTooLong(input, pureNumber))

OK

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/3134#discussion_r317364114
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20190824/79d9fd43/attachment.html>


More information about the bisq-github mailing list