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