Last active
August 29, 2015 14:13
-
-
Save nelanka/2018790c01e079d92679 to your computer and use it in GitHub Desktop.
Map an Option to a Scalactic Or
This file contains hidden or 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
object OptionToOr { | |
implicit class PimpedOption[T](opt: Option[T]) { | |
def orError(error: String): T Or Every[String] = opt match { | |
case Some(value) => Good(value) | |
case None => Bad(One(error)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment