apollo/filter
Create and use filters to narrow down on types
Functions
pub fn custom(v: Value, validator: fn(AnyType) ->
Result(Nil, String)) -> Value
Create a custom filter
Example
pub fn is_gleam(v: Value) {
custom(
v,
fn(value: AnyType) {
case value {
StringT(t) -> to_err(t == "Gleam", "Uh oh, expecting the word Gleam")
_ -> Error("Type mismatch, expecting String")
}
}
)
}
pub fn custom_string(v: Value, validator: fn(String) ->
Result(Nil, String)) -> Value
Shorthand to create a custom filter for only string types
Example
pub fn is_gleam(v: Value) {
custom_string(
v,
fn(t: String) {
to_err(t == "Gleam", "Uh oh, expecting the word Gleam")
}
)
}