Last active
January 10, 2021 23:20
-
-
Save hadilq/05fee577c141689db19f3783564713c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ValidationResultElseIfBuilder( | |
public val parent: ValidationResult | |
) { | |
public lateinit var result: Success | |
public inline fun InvalidEmailAddress(block: (errorMessage: String) -> Success): Unit { | |
if(parent is InvalidEmailAddress) { | |
result = block(parent.errorMessage) | |
} | |
} | |
public inline fun EmptySubject(block: (errorMessage: String) -> Success): Unit { | |
if(parent is EmptySubject) { | |
result = block(parent.errorMessage) | |
} | |
} | |
public inline fun EmptyBody(block: (errorMessage: String) -> Success): Unit { | |
if(parent is EmptyBody) { | |
result = block(parent.errorMessage) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment