Skip to content

Instantly share code, notes, and snippets.

@codenameone
Created February 4, 2018 06:50
Show Gist options
  • Save codenameone/6a67dd4d151bedf1bc3db6abb7b945ee to your computer and use it in GitHub Desktop.
Save codenameone/6a67dd4d151bedf1bc3db6abb7b945ee to your computer and use it in GitHub Desktop.
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