Package-level declarations
The core package hosts the main entrypoint of the library: The KResult class. It provides builders, transformers and extractors for result values and failures.
Functions
Link copied to clipboard
Transforms any element to a MultiErrorKResult, carrying a list of elements on Failure side
Link copied to clipboard
Transforms any element to a MultiValueKResult, carrying a list of elements on Success side
Link copied to clipboard
inline fun <E, T> KResult<E, T>.filter(failureValue: E, condition: (success: T) -> Boolean): KResult<E, T>
Syntactic sugar for filter where instead of a failure function, a value can be provided
Link copied to clipboard
If a KResult has a Throwable on failure side, this either returns the Success.value or throws the Failure.error
Link copied to clipboard
inline fun <E, T> MultiErrorKResult<E, T>.validate(failureValue: E, expectationFn: (success: T) -> Boolean): MultiErrorKResult<E, T>
Validates a Success or a FailureWithValue against a predicate (expectationFn] and applies failureValue if not fulfilled