https://github.com/austindd/rescript-validator
A composable data-validation library for ReScript
https://github.com/austindd/rescript-validator
Last synced: 5 months ago
JSON representation
A composable data-validation library for ReScript
- Host: GitHub
- URL: https://github.com/austindd/rescript-validator
- Owner: austindd
- Created: 2020-12-29T07:52:34.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-30T20:31:32.000Z (over 5 years ago)
- Last Synced: 2025-03-01T04:23:45.325Z (over 1 year ago)
- Language: ReScript
- Size: 117 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rescript-validator
A composable data-validation library for ReScript. Currently under construction.
The goal of this library is to allow users to intuitively compose a set of validators using boolean logic. For example:
```rescript
let isValidUserName = {
open Validator.StringValidators;
open Validator.Infix;
let isValidNonEmailHandle =
isLongerThan(3)
&& isShorterThan(65)
&& allCharsAreAscii
&& blacklistChars(bannedChars)
&& blacklistWords(bannedWords);
let isValidNonEmailHandle = useName("isValidNonEmailHandle", isValidNonEmailHandle);
useName("isValidUserName", isEmail || isValidNonEmailHandle);
}
let userName = "qF5wr*ywDLYta40^Dbwv";
let result = Validator.validate(isValidUserName, userName);
```
This ability to compose validators will hopefully make data validation feel intuitive and easy. Feel free to take a look and offer suggestions during development.