envie/schema

Types

pub type Field(a) {
  Field(
    meta: FieldMeta,
    run: fn() -> Result(a, error.Error),
    trace: fn() -> InspectField,
  )
}

Constructors

pub type FieldMeta {
  FieldMeta(
    name: String,
    optional: Bool,
    has_default: Bool,
    secret: Bool,
  )
}

Constructors

  • FieldMeta(
      name: String,
      optional: Bool,
      has_default: Bool,
      secret: Bool,
    )
pub type InspectField {
  InspectField(
    name: String,
    value: option.Option(String),
    used_default: Bool,
    optional: Bool,
    secret: Bool,
    error: option.Option(error.Error),
  )
}

Constructors

pub type Schema(a) {
  Schema(
    fields: List(FieldMeta),
    run: fn() -> Result(a, error.Error),
    trace: fn() -> List(InspectField),
  )
}

Constructors

Values

pub fn build1(field: Field(a)) -> Schema(a)
pub fn build2(
  first: Field(a),
  second: Field(b),
  build: fn(a, b) -> c,
) -> Schema(c)
pub fn build3(
  first: Field(a),
  second: Field(b),
  third: Field(c),
  build: fn(a, b, c) -> d,
) -> Schema(d)
pub fn default(field: Field(a), value: a) -> Field(a)
pub fn field(
  name: String,
  decoder: decode.Decoder(a),
) -> Field(a)
pub fn fields(schema: Schema(a)) -> List(FieldMeta)
pub fn inspect_fields(schema: Schema(a)) -> List(InspectField)
pub fn load(schema: Schema(a)) -> Result(a, error.Error)
pub fn load_field(field: Field(a)) -> Result(a, error.Error)
pub fn map2(
  first: Field(a),
  second: Field(b),
  build: fn(a, b) -> c,
) -> Schema(c)
pub fn optional(field: Field(a)) -> Field(option.Option(a))
pub fn secret(field: Field(a)) -> Field(a)
Search Document