Skip to content

Commit 6331966

Browse files
authored
feat: add extra validation for enums (#266)
Part of #253. Fixes several failing test cases identified in #261, getting us closer to being consistent with the schema.
1 parent 478aaca commit 6331966

File tree

2 files changed

+9
-0
lines changed
  • src/jvmMain/kotlin/it/krzeminski/githubactionstyping/validation/types

2 files changed

+9
-0
lines changed

src/jvmMain/kotlin/it/krzeminski/githubactionstyping/validation/types/Enum.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import it.krzeminski.githubactionstyping.parsing.ApiItem
44
import it.krzeminski.githubactionstyping.validation.ItemValidationResult
55

66
fun ApiItem.validateEnum(): ItemValidationResult {
7+
if (this.name?.isBlank() == true) {
8+
return ItemValidationResult.Invalid("Name must not be empty.")
9+
}
710
if (this.allowedValues == null) {
811
return ItemValidationResult.Invalid("Allowed values must be specified.")
912
}
@@ -19,5 +22,8 @@ fun ApiItem.validateEnum(): ItemValidationResult {
1922
if (this.allowedValues.isEmpty()) {
2023
return ItemValidationResult.Invalid("There must be at least one allowed value.")
2124
}
25+
if (this.allowedValues.any { it.isBlank() }) {
26+
return ItemValidationResult.Invalid("Allowed values must not be empty.")
27+
}
2228
return ItemValidationResult.Valid
2329
}

src/jvmMain/kotlin/it/krzeminski/githubactionstyping/validation/types/List.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ fun ApiItem.validateList(): ItemValidationResult {
1111
if (this.listItem == null) {
1212
return ItemValidationResult.Invalid("List item information must be specified.")
1313
}
14+
if (this.listItem.name?.isBlank() == true) {
15+
return ItemValidationResult.Invalid("List item type: Name must not be empty.")
16+
}
1417
if (this.separator == null) {
1518
return ItemValidationResult.Invalid("Separator must be specified.")
1619
}

0 commit comments

Comments
 (0)