/_includes/codeExamples/minitwit/17.validate_user_method.html

https://github.com/sparktutorials/sparktutorials.github.io · HTML · 15 lines · 13 code · 2 blank · 0 comment · 0 complexity · 7de12ef552e1d4a7da07a8ec4865f5c0 MD5 · raw file

  1. public String validate() {
  2. String error = null;
  3. if(StringUtils.isEmpty(username)) {
  4. error = "You have to enter a username";
  5. } else if(!EMAIL_ADDRESS_REGEX.matcher(email).matches()) {
  6. error = "You have to enter a valid email address";
  7. } else if(StringUtils.isEmpty(password)) {
  8. error = "You have to enter a password";
  9. } else if(!password.equals(password2)) {
  10. error = "The two passwords do not match";
  11. }
  12. return error;
  13. }