apollo

Functions

pub fn typed(type_: a, schema: List(#(String, Value))) -> Schema(
  b,
)

Returns a schema to be used by validate. Takes in a type constructor and a list of key, value pairs.

Example

 type Id {
   Id(id: String)
 }
 let res: t.Schema(Id) = typed(
     Id, 
     #(
         #("id", t.string())
     )
 )
pub fn validate(schema: Schema(a), obj: b) -> Result(a, String)

Takes in a schema from typed along with a mapping and returns a result of the type.

Example

 let res: t.Schema(Id) = typed(...)
 let assert Ok(my_id) = validate(res, [#("id", "1532594324")])
 // type of `my_id` is `Id`
Search Document