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

Stan notifications at github.com
Sat Aug 24 21:11:04 UTC 2019


ghubstan commented on this pull request.



> +    public PhoneNumberValidator(String isoCountryCode) {
+        this.isoCountryCode = isoCountryCode;
+        this.countryCallingCodes = new CountryCallingCodes();
+        this.callingCode = countryCallingCodes.getCallingCode(isoCountryCode);
+        this.normalizedCallingCode = countryCallingCodes.getNormalizedCallingCode(isoCountryCode);
+    }
+
+
+    @Override
+    public ValidationResult validate(String input) {
+        normalizedPhoneNumber = null;
+        ValidationResult result = super.validate(input);
+        if (!result.isValid) {
+            return result;
+        }
+        final String trimmedInput = input.trim();

But these are Java primitives.  Once set, final Strings and primitives are immutable.  (Class level final primitives must be set in in constructors, as I was doing in the hidden no-arg constructor.)   There are also tricks to create an immutable map (see CountryCallingCodes).

There are other scenarios where final primitives can be reassigned, such as ...

final int[] x = int[0];
function or anonymous inline class -->
  x[0] = 1;
  x[0] = 100;  
  etc...


-- 
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_r317374412
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20190824/4fb46ced/attachment.html>


More information about the bisq-github mailing list