Validated

endpoints4s.Validated
See theValidated companion trait
object Validated

Attributes

Companion
trait
Graph
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Validated.type

Members list

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def fromEither[A](either: Either[Seq[String], A]): Validated[A]

Turns an Either[Seq[String], A] into a Validated[A]

Turns an Either[Seq[String], A] into a Validated[A]

Attributes

def fromOption[A](maybeA: Option[A])(error: => String): Validated[A]

Turns None into an invalid value, using the given error message. Turns a Some[A] value into a Valid[A] value.

Turns None into an invalid value, using the given error message. Turns a Some[A] value into a Valid[A] value.

Attributes

def fromTry[A](tryA: Try[A]): Validated[A]

Turns a Success[A] into a Valid[A]

Turns a Success[A] into a Valid[A]

Turns a Failure[A] into an invalid value, using the exception message as an 'error' message

Attributes

def sequence[A, CC <: (IterableOnce)](in: CC[Validated[A]])(implicit bf: BuildFrom[CC[Validated[A]], A, CC[A]]): Validated[CC[A]]

Turns a collection of valid values into a valid collection of values. If all the values in the collection are Valid, the result will be Valid. If there is at least one Invalid, the result will be an Invalid containing the error messages of all Invalids If the collection is empty, it will return a Valid empty collection.

Turns a collection of valid values into a valid collection of values. If all the values in the collection are Valid, the result will be Valid. If there is at least one Invalid, the result will be an Invalid containing the error messages of all Invalids If the collection is empty, it will return a Valid empty collection.

Type parameters

A

the type of the Validated values (e.g. Int)

CC

the type of the collection of Validated values (e.g. List)

Value parameters

in

the collection of Validated values that will be sequenced

Attributes

Returns

the Validated of the resulting collection

See also

scala.concurrent.Future.sequence

def traverse[A, B, CC <: (IterableOnce)](in: CC[A])(fn: A => Validated[B])(implicit bf: BuildFrom[CC[A], B, CC[B]]): Validated[CC[B]]

Validates a collection of values using the provided function A => Validated[B] to validate every value. If all the values in the collection are Valid, the result will be Valid. If there is at least one Invalid, the result will be an Invalid containing the error messages of all Invalids If the collection is empty, it will return a Valid empty collection.

Validates a collection of values using the provided function A => Validated[B] to validate every value. If all the values in the collection are Valid, the result will be Valid. If there is at least one Invalid, the result will be an Invalid containing the error messages of all Invalids If the collection is empty, it will return a Valid empty collection.

  val myValidatedList = Validated.traverse(myList)(x => myValidateFunc(x))

Type parameters

A

the type of the values to be validated (e.g. String)

B

the type of the returned validated values (e.g. Int)

CC

the type of the collection of Validated (e.g. List)

Value parameters

fn

the validation function

in

the collection of values to be validated with the provided function

Attributes

Returns

the Validated of the resulting collection

See also

scala.concurrent.Future.traverse