Async validation library for node and browser


Keywords
handcuffs, async, validation, validator, validate, node, browser, data, laravel
License
MIT
Install
npm install handcuffs@0.6.0

Documentation

Handcuffs

Build Status

Validation library

Installation

Install using npm or yarn:

npm install handcuffs
yarn add handcuffs

Usage

Basic usage example:

import { validate } from 'handcuffs'

const data = {
  name: 'Jack',
  wife: {
    name: 'Susan'
  }
}

const rules = {
  name: 'required',
  'wife.name': 'required',
  pets: 'required|array'
}

const validationErrors = validate(data, rules)

Available Rules

Rule Example Description
accepted { rules: 'accepted' } The field under validation must be 'yes', 'on', 1, or true.
array { permissions: 'array' } The field under validation must be an array.
boolean { isVisible: 'boolean' } The field under validation must be a boolean value true or false.
required { name: 'required' } The field under validation must be present and not empty.