Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Portals committed Jun 27, 2024
1 parent d4056b4 commit 7534182
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,15 @@ public ModelAndView updateGroup(
checkForDuplicateEntries(form, bindingResult);

if (!bindingResult.hasErrors() && this.groupFacade.groupWithNameAlreadyExists(id, form.name)) {
bindingResult.addError(new FieldError("form", "name", "Group with name already exists"));
bindingResult.addError(
new FieldError(
"form",
"name",
form.name,
true,
null,
null,
"Group with name already exists"));
}

if (bindingResult.hasErrors()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public boolean groupWithNameAlreadyExists(UUID id, String name) {

Optional<Group> maybeGroup = this.groupRepository.get(new Name(name));

return maybeGroup.isEmpty() || !maybeGroup.get().id().value().equals(id);
return maybeGroup.filter(group -> !group.id().value().equals(id)).isPresent();
}

public Optional<GroupWithMembersDTO> getWithMembers(UUID groupId) {
Expand Down

0 comments on commit 7534182

Please sign in to comment.