valid/common

Types

Error type returned by the validator.

This is a # with the first error and a list of all errors. The list includes the first error.

pub type Errors(error) =
  #(error, List(error))

A Validator is a function that takes an input and returns a ValidatorResult

pub type Validator(input, output, error) =
  fn(input) -> ValidatorResult(output, error)
pub type ValidatorResult(output, error) =
  Result(output, Errors(error))

Functions

pub fn custom(
  error: a,
  check: fn(b) -> Option(c),
) -> fn(b) -> Result(c, #(a, List(a)))

Create a custom validator, see documentation in root module

Search Document