Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scull7/bs-awesomize
A ReasonML implementation of the Awesomize library for data validation / scrubbing
https://github.com/scull7/bs-awesomize
Last synced: about 1 month ago
JSON representation
A ReasonML implementation of the Awesomize library for data validation / scrubbing
- Host: GitHub
- URL: https://github.com/scull7/bs-awesomize
- Owner: scull7
- License: mit
- Created: 2018-03-23T22:51:34.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:57:31.000Z (almost 2 years ago)
- Last Synced: 2024-09-15T03:49:18.859Z (2 months ago)
- Language: Reason
- Size: 1.92 MB
- Stars: 1
- Watchers: 3
- Forks: 4
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://www.travis-ci.org/scull7/bs-awesomize.svg?branch=master)](https://www.travis-ci.org/scull7/bs-awesomize)
[![Coverage Status](https://coveralls.io/repos/github/scull7/bs-awesomize/badge.svg?branch=master)](https://coveralls.io/github/scull7/bs-awesomize?branch=master)# bs-awesomize
A ReasonML implementation of the Awesomize library for data validation / scrubbing# Why?
We use Awesomize to ensure that data which comes into our system
fits the proper shape and is within expected constraints. There are several
other libraries which aim to handle this, however, translating them to
ReasonML proved problematic. Also, the Awesomize library is asynchronous by
default which allows much greater flexibility in validation / scrubbing code.# Status
This library can be considered production ready.
# Installation
Inside of a BuckleScript project:
```sh
yarn add bs-awesomize
```Then add `bs-awesomize` to your `bs-dependencies` in your `bsconfig.json`
```json
{
"bs-dependencies": [ "bs-awesomize" ]
}
```# Usage
In order to use awesomize you will want to provide a "schema" which
consists of a map of `fields` to `field definitions`.## Field definition
```reason
type maybe = option(Js.Json.t);
type jsonMap = Belt.Map.String.t(maybe);type definition = {
read: Js.Dict.t(Js.Json.t) => Js.Promise.t(maybe),
sanitize: option((maybe, jsonMap) => Js.Promise.t(maybe)),
validate: list((maybe, jsonMap) => Js.Promise.t(option(string))),
normalize: option((maybe, jsonMap) => Js.Promise.t(maybe)),
};
```