glint/flag/constraint

Types

Constraint type for verifying flag values

pub type Constraint(a) =
  fn(a) -> Result(Nil)

Functions

pub fn each(constraint: fn(a) -> Result(Nil, Snag)) -> fn(List(a)) ->
  Result(Nil, Snag)

each is a convenience function for applying a Constraint(a) to a List(a). This is useful because the default behaviour for constraints on lists is that they will apply to the list as a whole.

For example, to apply one_of to all items in a List(Int):

[1, 2, 3, 4] |> one_of |> each
pub fn none_of(disallowed: List(a)) -> fn(a) -> Result(Nil, Snag)

none_of returns a Constraint that ensures the parsed flag value is not one of the disallowed values.

pub fn one_of(allowed: List(a)) -> fn(a) -> Result(Nil, Snag)

one_of returns a Constraint that ensures the parsed flag value is one of the allowed values.

Search Document