Skip to content

Commit

Permalink
Update DataMerge branch 'bertrick' of https://github.com/revaturelabs…
Browse files Browse the repository at this point in the history
blappa committed Feb 12, 2020
2 parents 177558a + a7dabce commit f3cd2b8
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/main/java/com/revature/controllers/UserController.java
Original file line number Diff line number Diff line change
@@ -174,7 +174,41 @@ public Map<String, Set<String>> addUser(@Valid @RequestBody User user, BindingRe
String code = fieldError.getCode();
String field = fieldError.getField();
if (code.equals("NotBlank") || code.equals("NotNull")) {
errors.computeIfAbsent(field, key -> new HashSet<>()).add(field+" required");
//
switch (field) {
case "userName":
errors.computeIfAbsent(field, key -> new HashSet<>()).add("Username field required");
break;
case "firstName":
errors.computeIfAbsent(field, key -> new HashSet<>()).add("First name field required");
break;
case "lastName":
errors.computeIfAbsent(field, key -> new HashSet<>()).add("Last name field required");
break;
case "wAddress":
errors.computeIfAbsent(field, key -> new HashSet<>()).add("Work address field required");
break;
case "wState":
case "hState":
errors.computeIfAbsent(field, key -> new HashSet<>()).add("State field required");
break;
case "phoneNumber":
errors.computeIfAbsent(field, key -> new HashSet<>()).add("Phone number field required");
break;
case "hAddress":
errors.computeIfAbsent(field, key -> new HashSet<>()).add("Home address field required");
break;
case "hZip":
case "wZip":
errors.computeIfAbsent(field, key -> new HashSet<>()).add("Zip code field required");
break;
case "hCity":
case "wCity":
errors.computeIfAbsent(field, key -> new HashSet<>()).add("City field required");
break;
default:
errors.computeIfAbsent(field, key -> new HashSet<>()).add(field+" required");
}
}
//username custom error message
else if (code.equals("Size") && field.equals("userName")) {
@@ -220,8 +254,11 @@ else if (code.equals("Pattern") && field.equals("phoneNumber")) {
}

if (errors.isEmpty()) {

user.setBatch(bs.getBatchByNumber(user.getBatch().getBatchNumber()));
us.addUser(user);


}
return errors;

0 comments on commit f3cd2b8

Please sign in to comment.