← ZIO Prelude docs

ZValidation

zio.prelude.ZValidation
See theZValidation companion object
sealed trait ZValidation[+W, +E, +A]

ZValidation represents either a success of type A or a collection of one or more errors of type E along with in either case a log with entries of type W. Unlike Either, ZValidation does not "short circuit" on failures and instead allows accumulating multiple errors. This can be particularly useful in validating data, where we want to attempt to validate all of the data and retain information about all errors that arose, rather than failing at the first error.

Attributes

Companion
object
Source
ZValidation.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Failure[W, E]
class Success[W, A]
Self type
ZValidation[W, E, A]

Members list

Value members

Concrete methods

final def &>[W1 >: W, E1 >: E, B](that: ZValidation[W1, E1, B]): ZValidation[W1, E1, B]

A symbolic alias for zipParRight.

A symbolic alias for zipParRight.

Attributes

Source
ZValidation.scala
final def <&[W1 >: W, E1 >: E, B](that: ZValidation[W1, E1, B]): ZValidation[W1, E1, A]

A symbolic alias for zipParLeft.

A symbolic alias for zipParLeft.

Attributes

Source
ZValidation.scala
final def <&>[W1 >: W, E1 >: E, B](that: ZValidation[W1, E1, B])(implicit zippable: Zippable[A, B]): ZValidation[W1, E1, zippable.Out]

A symbolic alias for zipPar.

A symbolic alias for zipPar.

Attributes

Source
ZValidation.scala
final def ??[W1 >: W](w1: W1): ZValidation[W1, E, A]

A symbolic alias for log.

A symbolic alias for log.

Attributes

Source
ZValidation.scala
final def as[B](b: B): ZValidation[W, E, B]

Maps the successful value of this ZValidation to the specified constant value.

Maps the successful value of this ZValidation to the specified constant value.

Attributes

Source
ZValidation.scala
final def asError[E2](e: E2): ZValidation[W, E2, A]

Maps the error value of this ZValidation to the specified constant value.

Maps the error value of this ZValidation to the specified constant value.

Attributes

Source
ZValidation.scala
final override def equals(that: Any): Boolean

Returns whether this ZValidation and the specified ZValidation are equal to each other.

Returns whether this ZValidation and the specified ZValidation are equal to each other.

Attributes

Definition Classes
Any
Source
ZValidation.scala
final def flatMap[W1 >: W, E1 >: E, B](f: A => ZValidation[W1, E1, B]): ZValidation[W1, E1, B]

Transforms the value of this ZValidation with the specified validation function if it is a success or returns the value unchanged otherwise.

Transforms the value of this ZValidation with the specified validation function if it is a success or returns the value unchanged otherwise.

Attributes

Source
ZValidation.scala
final def flatten[W1 >: W, E1 >: E, B](implicit ev1: A <:< ZValidation[W1, E1, B]): ZValidation[W1, E1, B]

Returns a ZValidation that is this ZValidation if failing or the inner ZValidation if the outer one succeeds. In particular, the sequential aspect of this combinator precludes combining error values of outer and inner ZValidations. This method can be used to "flatten" nested ZValidation.

Returns a ZValidation that is this ZValidation if failing or the inner ZValidation if the outer one succeeds. In particular, the sequential aspect of this combinator precludes combining error values of outer and inner ZValidations. This method can be used to "flatten" nested ZValidation.

Attributes

Source
ZValidation.scala
final def fold[B](failure: (NonEmptyChunk[E]) => B, success: A => B): B

Folds over the error and success values of this ZValidation.

Folds over the error and success values of this ZValidation.

Attributes

Source
ZValidation.scala
final def forEach[F[_] : Covariant, B](f: A => F[B]): F[ZValidation[W, E, B]]

Transforms the value of this ZValidation with the specified effectual function if it is a success or returns the value unchanged otherwise.

Transforms the value of this ZValidation with the specified effectual function if it is a success or returns the value unchanged otherwise.

Attributes

Source
ZValidation.scala
final def get(implicit ev: E <:< Nothing): A

Returns the value, because no error has occurred.

Returns the value, because no error has occurred.

Attributes

Source
ZValidation.scala
final def getLog: Chunk[W]

Returns the value of the log.

Returns the value of the log.

Attributes

Source
ZValidation.scala
final def getOrElse[A1 >: A](fallback: => A1): A1

Returns the value, if successful, or the provided fallback value.

Returns the value, if successful, or the provided fallback value.

Attributes

Source
ZValidation.scala
final def getOrElseWith[A1 >: A](f: (NonEmptyChunk[E]) => A1): A1

Returns the successful value or handles the errors that have accumulated.

Returns the successful value or handles the errors that have accumulated.

Attributes

Source
ZValidation.scala
final override def hashCode(): Int

Calculates a hash code value for the object.

Calculates a hash code value for the object.

The default hashing algorithm is platform dependent.

Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Attributes

Returns

the hash code value for this object.

Definition Classes
Any
Source
ZValidation.scala
final def isFailure: Boolean

Attributes

Source
ZValidation.scala
final def isSuccess: Boolean

Attributes

Source
ZValidation.scala
final def log[W1 >: W](w1: W1): ZValidation[W1, E, A]

Writes an entry to the log.

Writes an entry to the log.

Attributes

Source
ZValidation.scala
final def map[B](f: A => B): ZValidation[W, E, B]

Transforms the successful value of this ZValidation with the specified function.

Transforms the successful value of this ZValidation with the specified function.

Attributes

Source
ZValidation.scala
final def mapError[E2](f: E => E2): ZValidation[W, E2, A]

Transforms the error value of this ZValidation with the specified function.

Transforms the error value of this ZValidation with the specified function.

Attributes

Source
ZValidation.scala
final def mapErrorAll[E2](f: (NonEmptyChunk[E]) => NonEmptyChunk[E2]): ZValidation[W, E2, A]

Transforms all the error values of this ZValidation with the specified function.

Transforms all the error values of this ZValidation with the specified function.

Attributes

Source
ZValidation.scala
final def mapLog[W2](f: W => W2): ZValidation[W2, E, A]

Transforms the log entries of this ZValidation with the specified function.

Transforms the log entries of this ZValidation with the specified function.

Attributes

Source
ZValidation.scala
final def mapLogAll[W2](f: (Chunk[W]) => Chunk[W2]): ZValidation[W2, E, A]

Transforms all the log entries of this ZValidation with the specified function.

Transforms all the log entries of this ZValidation with the specified function.

Attributes

Source
ZValidation.scala
final def orElse[W1 >: W, E1, A1 >: A](that: => ZValidation[W1, E1, A1]): ZValidation[W1, E1, A1]

Attributes

Source
ZValidation.scala
final def orElseLog[W1 >: W, E1, A1 >: A](that: => ZValidation[W1, E1, A1])(implicit ev: E <:< W1): ZValidation[W1, E1, A1]

Attributes

Source
ZValidation.scala
final def runLog[B]: (Chunk[W], Either[NonEmptyChunk[E], A])

Exposes the result of this validation function as either a Right with a success of type A or a Left with one or more errors of type E, along with the log.

Exposes the result of this validation function as either a Right with a success of type A or a Left with one or more errors of type E, along with the log.

Attributes

Source
ZValidation.scala
final def tap[W1 >: W, E1 >: E](f: A => ZValidation[W1, E1, Any]): ZValidation[W1, E1, A]

Applies the provided validation function to the successful value of this ZValidation without altering the result. This method can be used to execute side effects or additional validations that do not transform the primary value but may modify the log or error. If this ZValidation is a failure, it remains unchanged.

Applies the provided validation function to the successful value of this ZValidation without altering the result. This method can be used to execute side effects or additional validations that do not transform the primary value but may modify the log or error. If this ZValidation is a failure, it remains unchanged.

Attributes

Source
ZValidation.scala
final def toEither: Either[NonEmptyChunk[E], A]

Transforms this ZValidation to an Either, discarding the log.

Transforms this ZValidation to an Either, discarding the log.

Attributes

Source
ZValidation.scala
final def toEitherAssociative[E1 >: E](implicit A: Associative[E1]): Either[E1, A]

Transforms this ZValidation to an Either, aggregating errors using provided Associative instance, discarding the log.

Transforms this ZValidation to an Either, aggregating errors using provided Associative instance, discarding the log.

Attributes

Source
ZValidation.scala
final def toEitherException(implicit ev: E <:< Throwable): Either[ZValidationException[W, E], A]

Transforms ZValidation to an Either, where the failure case will be represented as an Exception with the first error as cause.

Transforms ZValidation to an Either, where the failure case will be represented as an Exception with the first error as cause.

Attributes

Source
ZValidation.scala

Transforms this ZValidation to an Either, discarding the order in which the errors occurred and discarding the log.

Transforms this ZValidation to an Either, discarding the order in which the errors occurred and discarding the log.

Attributes

Source
ZValidation.scala
final def toEitherWith[E2](f: (NonEmptyChunk[E]) => E2): Either[E2, A]

Transforms this ZValidation to an Either, transforming the accumulated errors and discarding the log.

Transforms this ZValidation to an Either, transforming the accumulated errors and discarding the log.

Attributes

Source
ZValidation.scala
final def toFuture(implicit ev: E <:< Throwable): Future[A]

Transforms this ZValidation to a Future, discarding the log.

Transforms this ZValidation to a Future, discarding the log.

Attributes

Source
ZValidation.scala
final def toOption: Option[A]

Transforms this ZValidation to an Option, discarding information about the errors and log.

Transforms this ZValidation to an Option, discarding information about the errors and log.

Attributes

Source
ZValidation.scala
final def toTry(implicit ev: E <:< Throwable): Try[A]

Transforms this ZValidation to a Try, discarding the log.

Transforms this ZValidation to a Try, discarding the log.

Attributes

Source
ZValidation.scala
final def toZIO: IO[E, A]

Converts this ZValidation into a ZIO effect, discarding the log.

Converts this ZValidation into a ZIO effect, discarding the log.

Attributes

Source
ZValidation.scala
final def toZIOAssociative[E1 >: E](implicit A: Associative[E1]): IO[E1, A]

Transforms this ZValidation to an ZIO effect, aggregating errors using provided Associative instance, discarding the log.

Transforms this ZValidation to an ZIO effect, aggregating errors using provided Associative instance, discarding the log.

Attributes

Source
ZValidation.scala

Converts this ZValidation into a ZIO effect and exposes all parallel errors in a single call, discarding the log.

Converts this ZValidation into a ZIO effect and exposes all parallel errors in a single call, discarding the log.

Attributes

Source
ZValidation.scala
final def unit: ZValidation[W, E, Unit]

Transforms the successful output of this ZValidation into a Unit, effectively discarding the original success value while preserving any accumulated warnings or errors. This can be useful when the outcome of the validation process is not needed, but the side effects (e.g., logging or error accumulation) are important.

Transforms the successful output of this ZValidation into a Unit, effectively discarding the original success value while preserving any accumulated warnings or errors. This can be useful when the outcome of the validation process is not needed, but the side effects (e.g., logging or error accumulation) are important.

Attributes

Source
ZValidation.scala
final def zipPar[W1 >: W, E1 >: E, B](that: ZValidation[W1, E1, B])(implicit zippable: Zippable[A, B]): ZValidation[W1, E1, zippable.Out]

Combines this ZValidation with the specified ZValidation, returning a tuple of their results. Returns either the combined result if both were successes or otherwise returns a failure with all errors.

Combines this ZValidation with the specified ZValidation, returning a tuple of their results. Returns either the combined result if both were successes or otherwise returns a failure with all errors.

Attributes

Source
ZValidation.scala
final def zipParLeft[W1 >: W, E1 >: E, B](that: ZValidation[W1, E1, B]): ZValidation[W1, E1, A]

A variant of zipPar that keeps only the left success value, but returns a failure with all errors if either this ZValidation or the specified ZValidation fail.

A variant of zipPar that keeps only the left success value, but returns a failure with all errors if either this ZValidation or the specified ZValidation fail.

Attributes

Source
ZValidation.scala
final def zipParRight[W1 >: W, E1 >: E, B](that: ZValidation[W1, E1, B]): ZValidation[W1, E1, B]

A variant of zipPar that keeps only the right success value, but returns a failure with all errors if either this ZValidation or the specified ZValidation fail.

A variant of zipPar that keeps only the right success value, but returns a failure with all errors if either this ZValidation or the specified ZValidation fail.

Attributes

Source
ZValidation.scala
final def zipWithPar[W1 >: W, E1 >: E, B, C](that: ZValidation[W1, E1, B])(f: (A, B) => C): ZValidation[W1, E1, C]

Combines this ZValidation with the specified ZValidation, using the function f to combine their success values. Returns either the combined result if both were successes or otherwise returns a failure with all errors.

Combines this ZValidation with the specified ZValidation, using the function f to combine their success values. Returns either the combined result if both were successes or otherwise returns a failure with all errors.

Attributes

Source
ZValidation.scala