public static ValidationResult validateForLeave(String organizationName) {
Organization organization = Organization.findByName(organizationName);
if (organization == null) {
return new ValidationResult(notFound(getJsonErrorMsg("organization.member.unknownOrganization")), true);
}
if (OrganizationUser.isAdmin(organization.id, UserApp.currentUser().id)) {
if (OrganizationUser.findAdminsOf(organization).size() == 1) {
return new ValidationResult(forbidden(getJsonErrorMsg("organization.member.atLeastOneAdmin")), true);
}
}
return new ValidationResult(okWithLocation(routes.OrganizationApp.organization(organizationName).url()), false);
}