Valid

data class Valid<out A>(val value: A) : Validated<Nothing, A>

Constructors

Link copied to clipboard
fun <out A> Valid(value: A)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
inline fun all(predicate: (A) -> Boolean): Boolean
Link copied to clipboard
inline fun <B> bifoldLeft(    c: B,     fe: (B, Nothing) -> B,     fa: (B, A) -> B): B
Link copied to clipboard
inline fun <B> bifoldMap(    MN: Monoid<B>,     g: (Nothing) -> B,     f: (A) -> B): B
Link copied to clipboard
inline fun <EE, B> bimap(fe: (Nothing) -> EE, fa: (A) -> B): Validated<EE, B>

From arrow.typeclasses.Bifunctor, maps both types of this Validated.

Link copied to clipboard
inline fun <EE, B> bitraverse(fe: (Nothing) -> Iterable<EE>, fa: (A) -> Iterable<B>): List<Validated<EE, B>>
Link copied to clipboard
inline fun <EE, B, C> bitraverseEither(fe: (Nothing) -> Either<EE, B>, fa: (A) -> Either<EE, C>): Either<EE, Validated<B, C>>
Link copied to clipboard
inline fun <B, C> bitraverseNullable(fe: (Nothing) -> B?, fa: (A) -> C?): Validated<B, C>?
Link copied to clipboard
inline fun <B, C> bitraverseOption(fe: (Nothing) -> Option<B>, fa: (A) -> Option<C>): Option<Validated<B, C>>
Link copied to clipboard
inline fun exist(predicate: (A) -> Boolean): Boolean

Is this Valid and matching the given predicate

Link copied to clipboard
inline fun findOrNull(predicate: (A) -> Boolean): A?
Link copied to clipboard
inline fun <B> fold(fe: (Nothing) -> B, fa: (A) -> B): B
Link copied to clipboard
inline fun <B> foldLeft(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

Link copied to clipboard
inline fun <B> foldMap(MB: Monoid<B>, f: (A) -> B): B
Link copied to clipboard
fun isEmpty(): Boolean
Link copied to clipboard
fun isNotEmpty(): Boolean
Link copied to clipboard
inline fun <B> map(f: (A) -> B): Validated<Nothing, B>

Apply a function to a Valid value, returning a new Valid value

Link copied to clipboard
inline fun <EE> mapLeft(f: (Nothing) -> EE): Validated<EE, A>

Apply a function to an Invalid value, returning a new Invalid value. Or, if the original valid was Valid, return it.

Link copied to clipboard
fun swap(): Validated<A, Nothing>
Link copied to clipboard
inline fun tap(f: (A) -> Unit): Validated<Nothing, A>

The given function is applied as a fire and forget effect if this is Valid. When applied the result is ignored and the original Validated value is returned

Link copied to clipboard
inline fun tapInvalid(f: (Nothing) -> Unit): Validated<Nothing, A>

The given function is applied as a fire and forget effect if this is Invalid. When applied the result is ignored and the original Validated value is returned

Link copied to clipboard
fun toEither(): Either<Nothing, A>

Converts the value to an Either

Link copied to clipboard
fun toList(): List<A>

Convert this value to a single element List if it is Valid, otherwise return an empty List

Link copied to clipboard
fun toOption(): Option<A>

Returns Valid values wrapped in Some, and None for Invalid values

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun toValidatedNel(): ValidatedNel<Nothing, A>

Lift the Invalid value into a NonEmptyList.

Link copied to clipboard
inline fun <B> traverse(fa: (A) -> Iterable<B>): List<Validated<Nothing, B>>
Link copied to clipboard
inline fun <EE, B> traverseEither(fa: (A) -> Either<EE, B>): Either<EE, Validated<Nothing, B>>
Link copied to clipboard
inline fun <B> traverseNullable(fa: (A) -> B?): Validated<Nothing, B>?
Link copied to clipboard
inline fun <B> traverseOption(fa: (A) -> Option<B>): Option<Validated<Nothing, B>>
Link copied to clipboard
fun void(): Validated<Nothing, Unit>

Discards the A value inside Validated signaling this container may be pointing to a noop or an effect whose return value is deliberately ignored. The singleton value Unit serves as signal.

Link copied to clipboard
inline fun <EE, B> withEither(f: (Either<Nothing, A>) -> Either<EE, B>): Validated<EE, B>

Convert to an Either, apply a function, convert back. This is handy when you want to use the Monadic properties of the Either type.

Properties

Link copied to clipboard
val isInvalid: Boolean
Link copied to clipboard
val isValid: Boolean
Link copied to clipboard
val value: A