trust

Types

pub type DecodeError {
  DecodeError(
    message: String,
    path: List(String),
    error_kind: DecodeErrorKind,
  )
}

Constructors

  • DecodeError(
      message: String,
      path: List(String),
      error_kind: DecodeErrorKind,
    )
pub type DecodeErrorKind {
  TypeMismatch(expected: String, found: String)
  IntMinError(min: Int, actual: Int)
  IntMaxError(max: Int, actual: Int)
  FieldNotFound
  NotInStringEnum(available_keys: List(String), found: String)
  StringLenError(expected_length: Int, actual_length: Int)
  StringMinLenError(min_length: Int, actual_length: Int)
  StringMaxLenError(max_length: Int, actual_length: Int)
  TupleNegativeIndex(index: Int)
  TupleTooSmall(required_size: Int, actual_size: Int)
}

Constructors

  • TypeMismatch(expected: String, found: String)
  • IntMinError(min: Int, actual: Int)
  • IntMaxError(max: Int, actual: Int)
  • FieldNotFound
  • NotInStringEnum(available_keys: List(String), found: String)
  • StringLenError(expected_length: Int, actual_length: Int)
  • StringMinLenError(min_length: Int, actual_length: Int)
  • StringMaxLenError(max_length: Int, actual_length: Int)
  • TupleNegativeIndex(index: Int)
  • TupleTooSmall(required_size: Int, actual_size: Int)
pub type DecodeResult(t) =
  Result(t, List(DecodeError))
pub type Decoder(t) =
  fn(dynamic.Dynamic) -> DecodeResult(t)

Functions

pub fn bool(data: Dynamic) -> Result(Bool, List(DecodeError))
pub fn bool_literal(
  value: Bool,
) -> fn(Dynamic) -> Result(Bool, List(DecodeError))
pub fn bool_literal_with_message(
  value: Bool,
  message: String,
) -> fn(Dynamic) -> Result(Bool, List(DecodeError))
pub fn bool_with_message(
  message: String,
) -> fn(Dynamic) -> Result(Bool, List(DecodeError))
pub fn decode1(
  constructor: fn(a) -> b,
  t1: fn(Dynamic) -> Result(a, List(DecodeError)),
) -> fn(Dynamic) -> Result(b, List(DecodeError))
pub fn decode2(
  constructor: fn(a, b) -> c,
  t1: fn(Dynamic) -> Result(a, List(DecodeError)),
  t2: fn(Dynamic) -> Result(b, List(DecodeError)),
) -> fn(Dynamic) -> Result(c, List(DecodeError))
pub fn decode3(
  constructor: fn(a, b, c) -> d,
  t1: fn(Dynamic) -> Result(a, List(DecodeError)),
  t2: fn(Dynamic) -> Result(b, List(DecodeError)),
  t3: fn(Dynamic) -> Result(c, List(DecodeError)),
) -> fn(Dynamic) -> Result(d, List(DecodeError))
pub fn decode4(
  constructor: fn(a, b, c, d) -> e,
  t1: fn(Dynamic) -> Result(a, List(DecodeError)),
  t2: fn(Dynamic) -> Result(b, List(DecodeError)),
  t3: fn(Dynamic) -> Result(c, List(DecodeError)),
  t4: fn(Dynamic) -> Result(d, List(DecodeError)),
) -> fn(Dynamic) -> Result(e, List(DecodeError))
pub fn decode5(
  constructor: fn(a, b, c, d, e) -> f,
  t1: fn(Dynamic) -> Result(a, List(DecodeError)),
  t2: fn(Dynamic) -> Result(b, List(DecodeError)),
  t3: fn(Dynamic) -> Result(c, List(DecodeError)),
  t4: fn(Dynamic) -> Result(d, List(DecodeError)),
  t5: fn(Dynamic) -> Result(e, List(DecodeError)),
) -> fn(Dynamic) -> Result(f, List(DecodeError))
pub fn decode6(
  constructor: fn(a, b, c, d, e, f) -> g,
  t1: fn(Dynamic) -> Result(a, List(DecodeError)),
  t2: fn(Dynamic) -> Result(b, List(DecodeError)),
  t3: fn(Dynamic) -> Result(c, List(DecodeError)),
  t4: fn(Dynamic) -> Result(d, List(DecodeError)),
  t5: fn(Dynamic) -> Result(e, List(DecodeError)),
  t6: fn(Dynamic) -> Result(f, List(DecodeError)),
) -> fn(Dynamic) -> Result(g, List(DecodeError))
pub fn decode7(
  constructor: fn(a, b, c, d, e, f, g) -> h,
  t1: fn(Dynamic) -> Result(a, List(DecodeError)),
  t2: fn(Dynamic) -> Result(b, List(DecodeError)),
  t3: fn(Dynamic) -> Result(c, List(DecodeError)),
  t4: fn(Dynamic) -> Result(d, List(DecodeError)),
  t5: fn(Dynamic) -> Result(e, List(DecodeError)),
  t6: fn(Dynamic) -> Result(f, List(DecodeError)),
  t7: fn(Dynamic) -> Result(g, List(DecodeError)),
) -> fn(Dynamic) -> Result(h, List(DecodeError))
pub fn decode8(
  constructor: fn(a, b, c, d, e, f, g, h) -> i,
  t1: fn(Dynamic) -> Result(a, List(DecodeError)),
  t2: fn(Dynamic) -> Result(b, List(DecodeError)),
  t3: fn(Dynamic) -> Result(c, List(DecodeError)),
  t4: fn(Dynamic) -> Result(d, List(DecodeError)),
  t5: fn(Dynamic) -> Result(e, List(DecodeError)),
  t6: fn(Dynamic) -> Result(f, List(DecodeError)),
  t7: fn(Dynamic) -> Result(g, List(DecodeError)),
  t8: fn(Dynamic) -> Result(h, List(DecodeError)),
) -> fn(Dynamic) -> Result(i, List(DecodeError))
pub fn decode9(
  constructor: fn(a, b, c, d, e, f, g, h, i) -> j,
  t1: fn(Dynamic) -> Result(a, List(DecodeError)),
  t2: fn(Dynamic) -> Result(b, List(DecodeError)),
  t3: fn(Dynamic) -> Result(c, List(DecodeError)),
  t4: fn(Dynamic) -> Result(d, List(DecodeError)),
  t5: fn(Dynamic) -> Result(e, List(DecodeError)),
  t6: fn(Dynamic) -> Result(f, List(DecodeError)),
  t7: fn(Dynamic) -> Result(g, List(DecodeError)),
  t8: fn(Dynamic) -> Result(h, List(DecodeError)),
  t9: fn(Dynamic) -> Result(i, List(DecodeError)),
) -> fn(Dynamic) -> Result(j, List(DecodeError))
pub fn dict(
  key_decoder: fn(Dynamic) -> Result(a, List(DecodeError)),
  value_decoder: fn(Dynamic) -> Result(b, List(DecodeError)),
) -> fn(Dynamic) -> Result(Dict(a, b), List(DecodeError))
pub fn dynamic(
  value: Dynamic,
) -> Result(Dynamic, List(DecodeError))
pub fn element(
  index: Int,
  inner_decoder: fn(Dynamic) -> Result(a, List(DecodeError)),
) -> fn(Dynamic) -> Result(a, List(DecodeError))
pub fn element_with_message(
  index: Int,
  inner_decoder: fn(Dynamic) -> Result(a, List(DecodeError)),
  message: String,
) -> fn(Dynamic) -> Result(a, List(DecodeError))
pub fn field(
  name: String,
  inner_decoder: fn(Dynamic) -> Result(a, List(DecodeError)),
) -> fn(Dynamic) -> Result(a, List(DecodeError))
pub fn int(data: Dynamic) -> Result(Int, List(DecodeError))
pub fn int_literal(
  value: Int,
) -> fn(Dynamic) -> Result(Int, List(DecodeError))
pub fn int_literal_with_message(
  value: Int,
  message: String,
) -> fn(Dynamic) -> Result(Int, List(DecodeError))
pub fn int_max(
  source: fn(Dynamic) -> Result(Int, List(DecodeError)),
  max: Int,
) -> fn(Dynamic) -> Result(Int, List(DecodeError))
pub fn int_max_with_message(
  source: fn(Dynamic) -> Result(Int, List(DecodeError)),
  max: Int,
  message: String,
) -> fn(Dynamic) -> Result(Int, List(DecodeError))
pub fn int_min(
  source: fn(Dynamic) -> Result(Int, List(DecodeError)),
  min: Int,
) -> fn(Dynamic) -> Result(Int, List(DecodeError))
pub fn int_min_with_message(
  source: fn(Dynamic) -> Result(Int, List(DecodeError)),
  min: Int,
  message: String,
) -> fn(Dynamic) -> Result(Int, List(DecodeError))
pub fn int_with_message(
  message: String,
) -> fn(Dynamic) -> Result(Int, List(DecodeError))
pub fn map(
  source: fn(Dynamic) -> Result(a, List(DecodeError)),
  mapper: fn(a) -> b,
) -> fn(Dynamic) -> Result(b, List(DecodeError))
pub fn replace(
  source: fn(Dynamic) -> Result(a, List(DecodeError)),
  replace_value: b,
) -> fn(Dynamic) -> Result(b, List(DecodeError))
pub fn string(data: Dynamic) -> Result(String, List(DecodeError))
pub fn string_enum(
  source: fn(Dynamic) -> Result(String, List(DecodeError)),
  definition: List(#(String, a)),
) -> fn(Dynamic) -> Result(a, List(DecodeError))
pub fn string_enum_with_message(
  source: fn(Dynamic) -> Result(String, List(DecodeError)),
  definition: List(#(String, a)),
  message: String,
) -> fn(Dynamic) -> Result(a, List(DecodeError))
pub fn string_len(
  source: fn(Dynamic) -> Result(String, List(DecodeError)),
  len: Int,
) -> fn(Dynamic) -> Result(String, List(DecodeError))
pub fn string_len_with_message(
  source: fn(Dynamic) -> Result(String, List(DecodeError)),
  len: Int,
  message: String,
) -> fn(Dynamic) -> Result(String, List(DecodeError))
pub fn string_literal(
  value: String,
) -> fn(Dynamic) -> Result(String, List(DecodeError))
pub fn string_literal_with_message(
  value: String,
  message: String,
) -> fn(Dynamic) -> Result(String, List(DecodeError))
pub fn string_max_len(
  source: fn(Dynamic) -> Result(String, List(DecodeError)),
  max_len: Int,
) -> fn(Dynamic) -> Result(String, List(DecodeError))
pub fn string_max_len_with_message(
  source: fn(Dynamic) -> Result(String, List(DecodeError)),
  max_len: Int,
  message: String,
) -> fn(Dynamic) -> Result(String, List(DecodeError))
pub fn string_min_len(
  source: fn(Dynamic) -> Result(String, List(DecodeError)),
  min_len: Int,
) -> fn(Dynamic) -> Result(String, List(DecodeError))
pub fn string_min_len_with_message(
  source: fn(Dynamic) -> Result(String, List(DecodeError)),
  min_len: Int,
  message: String,
) -> fn(Dynamic) -> Result(String, List(DecodeError))
pub fn string_with_message(
  message: String,
) -> fn(Dynamic) -> Result(String, List(DecodeError))
Search Document