Skip to content

Commit 9dff7cc

Browse files
committed
add extra validation for selected features to be for users
1 parent 89d66ce commit 9dff7cc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/main/java/de/rwth/idsg/steve/web/dto/UserForm.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
package de.rwth.idsg.steve.web.dto;
2020

2121
import de.rwth.idsg.steve.NotificationFeature;
22+
import jakarta.validation.constraints.AssertTrue;
2223
import lombok.Getter;
2324
import lombok.Setter;
2425
import lombok.ToString;
26+
import org.apache.cxf.common.util.CollectionUtils;
2527
import org.joda.time.LocalDate;
2628

2729
import jakarta.validation.constraints.Email;
@@ -60,4 +62,19 @@ public class UserForm {
6062

6163
private Address address;
6264

65+
@AssertTrue(message = "Some of the selected notification features cannot be enabled for a user")
66+
public boolean isNotificationFeaturesForUser() {
67+
if (CollectionUtils.isEmpty(notificationFeatures)) {
68+
return true;
69+
}
70+
71+
for (var selectedFeature : notificationFeatures) {
72+
if (!selectedFeature.isForUser()) {
73+
return false;
74+
}
75+
}
76+
77+
return true;
78+
}
79+
6380
}

0 commit comments

Comments
 (0)