OkThen.Result.error_filter
You're seeing just the function
error_filter
, go back to OkThen.Result module for more information.
Link to this function
error_filter(result, check_function)
Specs
error_filter(result_input(), (any() -> as_boolean(any()))) :: result_input()
If result
is tagged :error
, passes the wrapped value into the provided function. If
check_function
returns a truthy value, result
is returned unchanged. Otherwise, returns
:none
.
Equivalent to tagged_filter(result, :error, check_function)
. See tagged_filter/3
.
Examples
iex> {:error, "hello"} |> Result.error_filter(&String.length(&1) == 5)
{:error, "hello"}
iex> {:error, "hello"} |> Result.error_filter(&String.length(&1) == 0)
:none
iex> :some |> Result.error_filter(&String.length(&1) == 0)
:some
iex> :ok |> Result.error_filter(&String.length(&1) == 0)
:ok
iex> nil |> Result.error_filter(&String.length(&1) == 0)
nil