Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aosasona/crossbar

Data validation library in pure Gleam
https://github.com/aosasona/crossbar

gleam validation-library

Last synced: about 2 months ago
JSON representation

Data validation library in pure Gleam

Awesome Lists containing this project

README

        

# crossbar

[![Package Version](https://img.shields.io/hexpm/v/crossbar)](https://hex.pm/packages/crossbar)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/crossbar/)

## Usage

```gleam
import gleam/io
import crossbar.{int, max_value, min_value, required, to_float, validate}

pub fn main() {
int("age", 16)
|> to_float
|> required
|> min_value(18.0)
|> max_value(21.0)
|> validate
|> io.debug
}
```

The snippet above will return the following error:

```gleam
Error([FailedRule("age", "min_value", "must be at least 18.0")])
```

## Installation

```sh
gleam add crossbar
```

Documentation can be found at .