Example #1
0
 private boolean checkInputErrors(User user, Model model) {
   boolean isErrorInput = false;
   if (!user.getEmail().matches(".+@.+\\..+") || user.getEmail().length() > 75) {
     model.addAttribute("notCorrectEmail", true);
     isErrorInput = true;
   }
   if (!user.getUsername().matches("[a-zA-Zà-ÿÀ-ß0-9_]+") || user.getUsername().length() > 30) {
     model.addAttribute("notCorrectUsername", true);
     isErrorInput = true;
   } else {
     if (userService.isRegistered(user.getUsername())) {
       model.addAttribute("usernameAlreadyRegistered", true);
       isErrorInput = true;
     }
   }
   if (!user.getPassword().matches("[a-zA-Zà-ÿÀ-ß0-9_]+") || user.getPassword().length() > 30) {
     model.addAttribute("notCorrectPassword", true);
     isErrorInput = true;
   }
   return isErrorInput;
 }