Skip to content

austindd/rescript-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

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.

About

A composable data-validation library for ReScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published