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 original Validated
.
This allows "chained" validation: the output of one validation can be fed into another validation function.
This function is similar to Xor.flatMap
. It's not called flatMap
,
because by Cats convention, flatMap
is a monadic bind that is consistent
with ap
. This method is not consistent with ap (or other
Apply
-based methods), because it has "fail-fast" behavior as opposed to
accumulating validation failures.
From Apply: if both the function and this value are Valid, apply the function
Validated is a functor.Bifunctor, this method applies one of the given functions.
Combine this Validated
with another Validated
, using the Semigroup
instances of the underlying E
and A
instances.
Combine this Validated
with another Validated
, using the Semigroup
instances of the underlying E
and A
instances. The resultant Validated
will be Valid
, if, and only if, both this Validated
instance and the
supplied Validated
instance are also Valid
.
Is this Valid and matching the given predicate
apply the given function to the value with the given B when valid, otherwise return the given B
Lazily-apply the given function to the value with the given B when valid, otherwise return the given B.
Is this Invalid or matching the predicate
Run the side-effecting function on the value if it is Valid
Return the Valid value, or the default if Invalid
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.
Apply a function to a Valid value, returning a new Valid value
Return this if it is Valid, or else fall back to the given default.
From Product
Converts the value to an Either[E,A]
Convert this value to a single element List if it is Valid, otherwise return an empty List
Returns Valid values wrapped in Some, and None for Invalid values
Lift the Invalid value into a NonEmptyList.
Convert this value to RightOr if Valid or LeftOr if Invalid
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
Convert to an Xor, apply a function, convert back.
Convert to an Xor, apply a function, convert back. This is handy when you want to use the Monadic properties of the Xor type.