sealed abstract class Validated[+E, +A] extends Product with Serializable
- Alphabetic
- By Inheritance
- Validated
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def ===[EE >: E, AA >: A](that: Validated[EE, AA])(implicit EE: Eq[EE], AA: Eq[AA]): Boolean
-
def
andThen[EE >: E, B](f: (A) ⇒ Validated[EE, B]): Validated[EE, B]
Apply a function (that returns a
Validated
) in the valid case.Apply a function (that returns a
Validated
) in the valid case. Otherwise return the originalValidated
.This allows "chained" validation: the output of one validation can be fed into another validation function.
This function is similar to
flatMap
onEither
. It's not calledflatMap
, because by Cats convention,flatMap
is a monadic bind that is consistent withap
. This method is not consistent with ap (or otherApply
-based methods), because it has "fail-fast" behavior as opposed to accumulating validation failures. -
def
ap[EE >: E, B](f: Validated[EE, (A) ⇒ B])(implicit EE: Semigroup[EE]): Validated[EE, B]
From Apply: if both the function and this value are Valid, apply the function
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
bimap[EE, AA](fe: (E) ⇒ EE, fa: (A) ⇒ AA): Validated[EE, AA]
Validated is a Bifunctor, this method applies one of the given functions.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
combine[EE >: E, AA >: A](that: Validated[EE, AA])(implicit EE: Semigroup[EE], AA: Semigroup[AA]): Validated[EE, AA]
Combine this
Validated
with anotherValidated
, using theSemigroup
instances of the underlyingE
andA
instances.Combine this
Validated
with anotherValidated
, using theSemigroup
instances of the underlyingE
andA
instances. The resultantValidated
will beValid
, if, and only if, both thisValidated
instance and the suppliedValidated
instance are alsoValid
. - def compare[EE >: E, AA >: A](that: Validated[EE, AA])(implicit EE: Order[EE], AA: Order[AA]): Int
-
def
ensure[EE >: E](onFailure: ⇒ EE)(f: (A) ⇒ Boolean): Validated[EE, A]
Ensure that a successful result passes the given predicate, falling back to an Invalid of
onFailure
if the predicate returns false.Ensure that a successful result passes the given predicate, falling back to an Invalid of
onFailure
if the predicate returns false.For example:
scala> Validated.valid("").ensure(new IllegalArgumentException("Must not be empty"))(_.nonEmpty) res0: Validated[IllegalArgumentException, String] = Invalid(java.lang.IllegalArgumentException: Must not be empty)
-
def
ensureOr[EE >: E](onFailure: (A) ⇒ EE)(f: (A) ⇒ Boolean): Validated[EE, A]
Ensure that a successful result passes the given predicate, falling back to the an Invalid of the result of
onFailure
if the predicate returns false.Ensure that a successful result passes the given predicate, falling back to the an Invalid of the result of
onFailure
if the predicate returns false.For example:
scala> Validated.valid("ab").ensureOr(s => new IllegalArgumentException("Must be longer than 3, provided '" + s + "'"))(_.length > 3) res0: Validated[IllegalArgumentException, String] = Invalid(java.lang.IllegalArgumentException: Must be longer than 3, provided 'ab')
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
exists(predicate: (A) ⇒ Boolean): Boolean
Is this Valid and matching the given predicate
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
findValid[EE >: E, AA >: A](that: ⇒ Validated[EE, AA])(implicit EE: Semigroup[EE]): Validated[EE, AA]
If
this
is valid returnthis
, otherwise ifthat
is valid returnthat
, otherwise combine the failures.If
this
is valid returnthis
, otherwise ifthat
is valid returnthat
, otherwise combine the failures. This is similar to orElse except that here failures are accumulated. - def fold[B](fe: (E) ⇒ B, fa: (A) ⇒ B): B
-
def
foldLeft[B](b: B)(f: (B, A) ⇒ B): B
apply the given function to the value with the given B when valid, otherwise return the given B
-
def
foldRight[B](lb: Eval[B])(f: (A, Eval[B]) ⇒ Eval[B]): Eval[B]
Lazily-apply the given function to the value with the given B when valid, otherwise return the given B.
-
def
forall(f: (A) ⇒ Boolean): Boolean
Is this Invalid or matching the predicate
-
def
foreach(f: (A) ⇒ Unit): Unit
Run the side-effecting function on the value if it is Valid
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getOrElse[B >: A](default: ⇒ B): B
Return the Valid value, or the default if Invalid
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isInvalid: Boolean
- def isValid: Boolean
-
def
leftMap[EE](f: (E) ⇒ EE): Validated[EE, A]
Apply a function to an Invalid value, returning a new Invalid value.
Apply a function to an Invalid value, returning a new Invalid value. Or, if the original valid was Valid, return it.
-
def
map[B](f: (A) ⇒ B): Validated[E, B]
Apply a function to a Valid value, returning a new Valid value
- def merge[EE >: E](implicit ev: <:<[A, EE]): EE
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
orElse[EE, AA >: A](default: ⇒ Validated[EE, AA]): Validated[EE, AA]
Return this if it is Valid, or else fall back to the given default.
Return this if it is Valid, or else fall back to the given default. The functionality is similar to that of findValid except for failure accumulation, where here only the error on the right is preserved and the error on the left is ignored.
- def partialCompare[EE >: E, AA >: A](that: Validated[EE, AA])(implicit EE: PartialOrder[EE], AA: PartialOrder[AA]): Double
-
def
product[EE >: E, B](fb: Validated[EE, B])(implicit EE: Semigroup[EE]): Validated[EE, (A, B)]
From Product
-
def
productIterator: Iterator[Any]
- Definition Classes
- Product
-
def
productPrefix: String
- Definition Classes
- Product
- def show[EE >: E, AA >: A](implicit EE: Show[EE], AA: Show[AA]): String
- def swap: Validated[A, E]
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toEither: Either[E, A]
Converts the value to an Either[E, A]
-
def
toIor: Ior[E, A]
Returns Valid values wrapped in Ior.Right, and None for Ior.Left values
-
def
toList: List[A]
Convert this value to a single element List if it is Valid, otherwise return an empty List
-
def
toOption: Option[A]
Returns Valid values wrapped in Some, and None for Invalid values
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
toValidatedNec[EE >: E, AA >: A]: ValidatedNec[EE, AA]
Lift the Invalid value into a NonEmptyChain.
-
def
toValidatedNel[EE >: E, AA >: A]: ValidatedNel[EE, AA]
Lift the Invalid value into a NonEmptyList.
-
def
traverse[F[_], EE >: E, B](f: (A) ⇒ F[B])(implicit F: Applicative[F]): F[Validated[EE, B]]
When Valid, apply the function, marking the result as valid inside the Applicative's context, when Invalid, lift the Error into the Applicative's context
-
def
valueOr[B >: A](f: (E) ⇒ B): B
Return the Valid value, or the result of f if Invalid
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
withEither[EE, B](f: (Either[E, A]) ⇒ Either[EE, B]): Validated[EE, B]
Convert to an Either, apply a function, convert back.
Convert to an Either, apply a function, convert back. This is handy when you want to use the Monadic properties of the Either type.