Trait/Object

play.api.data.mapping

Validation

Related Docs: object Validation | package mapping

Permalink

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
Visibility
  1. Public
  2. All

Type Members

  1. final class WithFilter extends AnyRef

    Permalink

Abstract Value Members

  1. abstract def get: A

    Permalink

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

Concrete Value Members

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

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

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

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

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

    Permalink

    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

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

    Permalink

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

  8. def clone(): AnyRef

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

    Permalink

    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

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

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

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

    Permalink

    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]

    Permalink

    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]

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

    Permalink
  17. def finalize(): Unit

    Permalink
    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

    Permalink

    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

    Permalink

    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[_]

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

    Permalink

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

  22. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  23. def isFailure: Boolean

    Permalink
  24. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  25. def isSuccess: Boolean

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

    Permalink

    [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

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

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

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

    Permalink

    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]

    Permalink

    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

    Permalink

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

  33. def success: SuccessProjection[E, A]

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

    Permalink
    Definition Classes
    AnyRef
  35. def toString(): String

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

    Permalink
  37. final def wait(): Unit

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

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

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

    Permalink

    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