Skip to content

Commit 9247c15

Browse files
authored
Merge pull request #8 from theSimpleCloud/refactor/group-memory-validation
refactor: add memory validation on group creation
2 parents d45dc73 + 95b0fba commit 9247c15

File tree

1 file changed

+10
-0
lines changed
  • controller-runtime/src/main/kotlin/app/simplecloud/controller/runtime/group

1 file changed

+10
-0
lines changed

controller-runtime/src/main/kotlin/app/simplecloud/controller/runtime/group/GroupService.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ class GroupService(
3434
groupRepository.find(request.group.name)
3535
?: throw StatusException(Status.NOT_FOUND.withDescription("This group does not exist"))
3636
val group = Group.fromDefinition(request.group)
37+
38+
if (group.minMemory > group.maxMemory) {
39+
throw StatusException(Status.INVALID_ARGUMENT.withDescription("Minimum memory must be smaller than maximum memory"))
40+
}
41+
3742
try {
3843
groupRepository.save(group)
3944
} catch (e: Exception) {
@@ -47,6 +52,11 @@ class GroupService(
4752
throw StatusException(Status.NOT_FOUND.withDescription("This group already exists"))
4853
}
4954
val group = Group.fromDefinition(request.group)
55+
56+
if (group.minMemory > group.maxMemory) {
57+
throw StatusException(Status.INVALID_ARGUMENT.withDescription("Minimum memory must be smaller than maximum memory"))
58+
}
59+
5060
try {
5161
groupRepository.save(group)
5262
} catch (e: Exception) {

0 commit comments

Comments
 (0)