toErrorIf
inline fun <T> AsyncResult<T>.toErrorIf(predicate: (T) -> Boolean, error: (T) -> Error = { Error.Empty }): AsyncResult<T>
Converts a Success to an Error if the predicate returns true for the success value. Other states (Loading, NotStarted, Error) are returned unchanged.
Return
The original AsyncResult if predicate is false or not Success, otherwise an Error.
Parameters
predicate
Function that receives the success value and returns true if it should become an error.
error
Optional function to create a custom Error from the success value. Defaults to Error.Empty.