play.api.data.mapping

Validation

sealed trait Validation[+E, +A] extends AnyRef

Validation[E, A] is the result of a validation, where E is the type of each error, and A is the type of the result if the validation is successful The only two possible implementations are Success[E, A](value: A), or Failure[E, A](errors: Seq[E])

Self Type
Validation[E, A]
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Validation
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. final class WithFilter extends AnyRef

Abstract Value Members

  1. abstract def get: A

    Returns the value from this Success or throws the exception if this is a Failure.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. def *>[EE >: E, B](o: Validation[EE, B]): Validation[EE, B]

  4. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  5. def asEither: Either[Seq[E], A]

    Returns Left containing the errors if this is a Failure or a Right containing the value if this is a Success.

  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def asOpt: Option[A]

    Returns None if this is a Failure or a Some containing the value if this is a Success.

  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def collect[EE >: E, B](otherwise: EE)(p: PartialFunction[A, B]): Validation[EE, B]

    Like map, but for partial function.

    Like map, but for partial function. If p us not defined for the value, it return a Failure

    val p: PartialFunction[Int, String] = { case 5 => "High five!" }
    Success(5).collect("OOoops")(p) == Success("High five!")
    Success(7).collect("OOoops")(p) == Failure(Seq("OOoops"))
    Failure(Seq("error")).collect("OOoops")(p) == Failure(Seq("error"))
    otherwise

    the error to return if the p is not defined

    p

    the partial function to apply if this is a Success

    returns

    a Success if this was a Success and p was defined, a Failure otherwise

  10. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  12. def fail: FailProjection[E, A]

  13. def filter[EE >: E](otherwise: EE)(p: (A) ⇒ Boolean): Validation[EE, A]

    filter Successful Validation if it does not match the predicate p

    filter Successful Validation if it does not match the predicate p

    val isFive: Int => Boolean = _ == 5
    Success(5).filter("Not five")(isFive) == Success(5)
    Success(7).filter("Not five")(isFive) == Failure(Seq("Not five"))
    Failure(Seq("error")).filter("Not five")(isFive) == Failure(Seq("error"))
    otherwise

    the error to return if the predicate p is not verified

    p

    the predicate to apply if this is a Success

    returns

    a Success if this was a Success and the predicate matched, a Failure otherwise

  14. def filter(p: (A) ⇒ Boolean): Validation[E, A]

    filter Successful Validation if it does not match the predicate p

    filter Successful Validation if it does not match the predicate p

    p

    the predicate to apply if this is a Success

    returns

    a Success if this was a Success and the predicate matched, a Failure otherwise

  15. def filterNot(p: (A) ⇒ Boolean): Validation[E, A]

  16. def filterNot[EE >: E](error: EE)(p: (A) ⇒ Boolean): Validation[EE, A]

  17. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. def fold[X](invalid: (Seq[E]) ⇒ X, valid: (A) ⇒ X): X

    Applies invalid if this is a Failure or valid if this is a Success.

    Applies invalid if this is a Failure or valid if this is a Success.

    invalid

    the function to apply if this is a Failure

    valid

    the function to apply if this is a Success

    returns

    the results of applying the function

  19. def foreach(f: (A) ⇒ Unit): Unit

    Applies the given function f if this is a Success, otherwise returns Unit if this is a Failure

    Applies the given function f if this is a Success, otherwise returns Unit if this is a Failure

    f

    the function to apply if this is a Success

    returns

    Unit

  20. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  21. def getOrElse[AA >: A](t: ⇒ AA): AA

    Returns the value from this Success or returns t if this is a Failure.

  22. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  23. def isFailure: Boolean

  24. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  25. def isSuccess: Boolean

  26. def map[X](f: (A) ⇒ X): Validation[E, X]

    [use case] Builds a new Validation by applying a function to the value of this validation if it's a Success

    [use case] Builds a new Validation by applying a function to the value of this validation if it's a Success

    val f: Int => Int = _ + 2
    Success(5).map(f) == Success(7)
    Failure(Seq("error")).map(f) == Failure(Seq("error"))
    f

    the function to apply if this is a Success

    returns

    the result of applying the function

  27. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  28. final def notify(): Unit

    Definition Classes
    AnyRef
  29. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  30. def orElse[EE >: E, AA >: A](t: ⇒ Validation[EE, AA]): Validation[EE, AA]

    Returns this Validation if it is a Success or returns t if it is a Failure.

  31. def recover[AA >: A](errManager: PartialFunction[Failure[E, A], AA]): Validation[E, AA]

    Applies the given partial function errManager if this is a Failure, otherwise returns this if this is a Success.

  32. def recoverTotal[AA >: A](errManager: (Failure[E, A]) ⇒ AA): AA

    Applies the given function errManager if this is a Failure, otherwise returns this if this is a Success.

  33. def success: SuccessProjection[E, A]

  34. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  35. def toString(): String

    Definition Classes
    AnyRef → Any
  36. def viaEither[EE, AA](f: (Either[Seq[E], A]) ⇒ Either[Seq[EE], AA]): Validation[EE, AA]

  37. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. def withFilter(p: (A) ⇒ Boolean): WithFilter

    Creates a non-strict filter of this Validation.

    Creates a non-strict filter of this Validation.

    Note: the difference between c filter p and c withFilter p is that the former creates a new vlaidation, whereas the latter only restricts the domain of subsequent map, flatMap, foreach, and withFilter operations.

    p

    the predicate used to test value.

    returns

    an object of class WithFilter, which supports map, flatMap, foreach, and withFilter operations. All these operations apply to the value of this Validation which satisfy the predicate p.

Inherited from AnyRef

Inherited from Any

Ungrouped