Skip to content

Commit

Permalink
feat: add validation for integer's named values
Browse files Browse the repository at this point in the history
Part of #253.

It brings consistency with the rules defined in the schema.
  • Loading branch information
krzema12 committed Jan 31, 2025
1 parent 6331966 commit ca1309f
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ fun ApiItem.validateInteger(): ItemValidationResult {
if ((this.namedValues == null) && (this.name != null)) {
return ItemValidationResult.Invalid("'name' is only allowed for this type when also having 'named-values'.")
}
if (this.namedValues?.isEmpty() == true) {
return ItemValidationResult.Invalid("There must be at least one named value.")
}
if (this.namedValues?.keys?.any { it.isBlank() } == true) {
return ItemValidationResult.Invalid("Named value names must not be empty.")
}
if (this.allowedValues != null) {
return ItemValidationResult.Invalid("'allowed-values' is not allowed for this type.")
}
Expand Down

0 comments on commit ca1309f

Please sign in to comment.