Skip to content

Commit ca1309f

Browse files
committed
feat: add validation for integer's named values
Part of #253. It brings consistency with the rules defined in the schema.
1 parent 6331966 commit ca1309f

File tree

1 file changed

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

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ fun ApiItem.validateInteger(): ItemValidationResult {
77
if ((this.namedValues == null) && (this.name != null)) {
88
return ItemValidationResult.Invalid("'name' is only allowed for this type when also having 'named-values'.")
99
}
10+
if (this.namedValues?.isEmpty() == true) {
11+
return ItemValidationResult.Invalid("There must be at least one named value.")
12+
}
13+
if (this.namedValues?.keys?.any { it.isBlank() } == true) {
14+
return ItemValidationResult.Invalid("Named value names must not be empty.")
15+
}
1016
if (this.allowedValues != null) {
1117
return ItemValidationResult.Invalid("'allowed-values' is not allowed for this type.")
1218
}

0 commit comments

Comments
 (0)