8000 feat: add extra validation for enums by krzema12 · Pull Request #266 · typesafegithub/github-actions-typing · GitHub
[go: up one dir, main page]

Skip to content

feat: add extra validation for enums #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import it.krzeminski.githubactionstyping.parsing.ApiItem
import it.krzeminski.githubactionstyping.validation.ItemValidationResult

fun ApiItem.validateEnum(): ItemValidationResult {
if (this.name?.isBlank() == true) {
return ItemValidationResult.Invalid("Name must not be empty.")
}
if (this.allowedValues == null) {
return ItemValidationResult.Invalid("Allowed values must be specified.")
}
Expand All @@ -19,5 +22,8 @@ fun ApiItem.validateEnum(): ItemValidationResult {
if (this.allowedValues.isEmpty()) {
return ItemValidationResult.Invalid("There must be at least one allowed value.")
}
if (this.allowedValues.any { it.isBlank() }) {
return ItemValidationResult.Invalid("Allowed values must not be empty.")
}
return ItemValidationResult.Valid
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ fun ApiItem.validateList(): ItemValidationResult {
if (this.listItem == null) {
return ItemValidationResult.Invalid("List item information must be specified.")
}
if (this.listItem.name?.isBlank() == true) {
return ItemValidationResult.Invalid("List item type: Name must not be empty.")
}
if (this.separator == null) {
return ItemValidationResult.Invalid("Separator must be specified.")
}
Expand Down
Loading
0