Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sporto/gleam-valid
Validation library for Gleam
https://github.com/sporto/gleam-valid
gleam gleam-lang
Last synced: 5 days ago
JSON representation
Validation library for Gleam
- Host: GitHub
- URL: https://github.com/sporto/gleam-valid
- Owner: sporto
- License: apache-2.0
- Created: 2020-10-16T01:07:45.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-23T13:27:48.000Z (4 months ago)
- Last Synced: 2024-09-17T08:52:12.814Z (about 2 months ago)
- Topics: gleam, gleam-lang
- Language: Gleam
- Homepage: https://hexdocs.pm/valid
- Size: 108 KB
- Stars: 28
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gleam - valid - [📚](https://hexdocs.pm/valid/) - A composable validation library for Gleam (Packages / Validation)
README
# Valid
![CI](https://github.com/sporto/gleam-valid/workflows/test/badge.svg?branch=main)
A validation library for [Gleam](https://gleam.run/).
API Docs: .
This library follows the principle [Parse don't validate](https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/).
```gleam
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
- For basic usage see
### Validators
- For string validators, see
- For int validators, see
- For list validators, see
- For optional validators, see
- For creating a custom validator, see### Composition
- For composing validators, see
### Other
- For validating a dictionary, see
- For custom error types, see
- For validating a whole structure, see