Skip to content

Instantly share code, notes, and snippets.

@hadilq
Created January 10, 2021 23:05
Show Gist options
  • Save hadilq/b4fb6fa137faa063cd4b2f589a7f6fff to your computer and use it in GitHub Desktop.
Save hadilq/b4fb6fa137faa063cd4b2f589a7f6fff to your computer and use it in GitHub Desktop.
Validate in doWork method
doWork() : Result<Email> {
...
validate() elseIf {
InvalidEmailAddress { errorMessage: String ->
return Failure(errorMessage)
}
EmptySubject { errorMessage: String -> /* handle failure */ }
EmptyBody { errorMessage: String -> /* handle failure */ }
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment