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")
       }
     )
  }
pub fn length(v: Value, length l: Int) -> Value
pub fn max(v: Value, length l: Int) -> Value
pub fn min(v: Value, length l: Int) -> Value
pub fn regex(v: Value, regex re: Regex) -> Value
Search Document