Skip to content

Commit

Permalink
Add valueOr to Validated, analog to Xor.valueOr
Browse files Browse the repository at this point in the history
  • Loading branch information
mkotsbakws committed Jun 14, 2016
1 parent b149835 commit 26a044b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/src/main/scala/cats/data/Validated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ sealed abstract class Validated[+E, +A] extends Product with Serializable {
*/
def getOrElse[B >: A](default: => B): B = fold(_ => default, identity)

/**
* Return the Valid value, or the result of f if Invalid
*/
def valueOr[B >: A](f: E => B): B = fold(f, identity)

/**
* Is this Valid and matching the given predicate
*/
Expand Down

0 comments on commit 26a044b

Please sign in to comment.