Skip to content

Instantly share code, notes, and snippets.

@hadilq
Created January 10, 2021 23:07
Show Gist options
  • Save hadilq/312ae73f4cde40d8558200b02935e467 to your computer and use it in GitHub Desktop.
Save hadilq/312ae73f4cde40d8558200b02935e467 to your computer and use it in GitHub Desktop.
Validate DSL extension function
public inline infix fun ValidationResult.elseIf(build: ValidationResultElseIfBuilder.() -> Unit):
Success {
if (this is Success) {
return this
} else {
val builder = ValidationResultElseIfBuilder(this)
builder.build()
return builder.result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment