Created
February 4, 2018 06:50
-
-
Save codenameone/6a67dd4d151bedf1bc3db6abb7b945ee to your computer and use it in GitHub Desktop.
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
val.addConstraint(phone, new Constraint() { | |
public boolean isValid(Object value) { | |
String v = (String)value; | |
for(int i = 0 ; i < v.length() ; i++) { | |
char c = v.charAt(i); | |
if(c >= '0' && c <= '9' || c == '+' || c == '-') { | |
continue; | |
} | |
return false; | |
} | |
return true; | |
} | |
public String getDefaultFailMessage() { | |
return "Must be valid phone number"; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment