Valid

CI

A validation library for Gleam.

API Docs: https://hexdocs.pm/valid.

This library follows the principle Parse don’t validate.

fn user_validator(user: InputUser) -> ValidatorResult(ValidUser, String) {
  valid.build3(ValidUser)
  |> valid.check(user.name, valid.is_some("Please provide a name"))
  |> valid.check(user.email, valid.is_some("Please provide an email"))
  |> valid.check(user.age, valid.ok())
}

case user_valid(input) {
  Ok(valid_user) -> ...
  Error(errors) -> ...
}

Install

gleam add valid

Usage and Examples

Validators

Composition

Other

Search Document