npm.io
0.0.2 • Published 5 years ago

@mikrav/reval

Licence
MIT
Version
0.0.2
Deps
1
Size
32 kB
Vulns
0
Weekly
0

Reval

Simple validation schema for Rescript.

Install

npm install @mikrav/reval

Usage

open Reval

let schema = Schema.Dict(
  [RequiredKeys(["name", "age"])],
  [
    //
    ("name", String([MinLength(2)])),
    ("age", Int([GTE(0)])),
    ("description", String([NotEmpty])),
  ],
)

let input = Input.Dict([
  //
  ("name", String("Moona"))
  ("age", Int(3)),
  ("description", String("Hello"))
])

validate(schema, input)

// output:
// result<Input.t, Error.t>

Keywords