2.0.0 • Published 4 years ago

bs-awesomize v2.0.0

Weekly downloads
81
License
MIT
Repository
github
Last release
4 years ago

Build Status Coverage Status

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:

yarn add bs-awesomize

Then add bs-awesomize to your bs-dependencies in your bsconfig.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

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)),
};
2.0.0

4 years ago

1.6.0

6 years ago

1.5.0

6 years ago

1.4.11

6 years ago

1.4.10

6 years ago

1.4.9

6 years ago

1.4.8

6 years ago

1.4.7

6 years ago

1.4.6

6 years ago

1.4.5

6 years ago

1.4.4

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago