Skip to content

Commit

Permalink
Merge pull request #605 from ceedubs/rm-validated-filter
Browse files Browse the repository at this point in the history
Remove Validated.filter
  • Loading branch information
adelbertc committed Nov 9, 2015
2 parents a38fdb2 + c0deecf commit 912df33
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 17 deletions.
9 changes: 0 additions & 9 deletions core/src/main/scala/cats/data/Validated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ sealed abstract class Validated[+E, +A] extends Product with Serializable {
*/
def forall(f: A => Boolean): Boolean = fold(_ => true, f)

/**
* If the value is Valid but the predicate fails, return an empty
* Invalid value, otherwise leaves the value unchanged. This method
* is mostly useful for allowing validated values to be used in a
* for comprehension with pattern matching.
*/
def filter[EE >: E](pred: A => Boolean)(implicit M: Monoid[EE]): Validated[EE,A] =
fold(Invalid.apply, a => if(pred(a)) this else Invalid(M.empty))

/**
* Return this if it is Valid, or else fall back to the given default.
*/
Expand Down
8 changes: 0 additions & 8 deletions tests/src/test/scala/cats/tests/ValidatedTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ class ValidatedTests extends CatsSuite {
}
}

test("filter makes non-matching entries invalid") {
Valid(1).filter[String](_ % 2 == 0).isInvalid should ===(true)
}

test("filter leaves matching entries valid") {
Valid(2).filter[String](_ % 2 == 0).isValid should ===(true)
}

test("ValidatedNel") {
forAll { (e: String) =>
val manual = Validated.invalid[NonEmptyList[String], Int](NonEmptyList(e))
Expand Down

0 comments on commit 912df33

Please sign in to comment.