Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

handcuffs

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

handcuffs

Validation library

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Handcuffs

Build Status Test Coverage

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

RuleExampleDescription
accepted{ rules: 'accepted' }The field under validation must be 'yes', 'on', 1, or true.
alpha{ name: 'alpha' }The field under validation must be entirely alphabetic characters.
alphaDash{ slug: 'alphaDash' }The field under validation may have alpha-numeric characters, as well as dashes and underscores.
alphaNum{ password: 'alphaNum' }The field under validation must be entirely alpha-numeric characters.
array{ permissions: 'array' }The field under validation must be an array.
between{ guests: 'between:1,3' }The field under validation must have a size between the given min and max values.
boolean{ isVisible: 'boolean' }The field under validation must be a boolean value true or false.
max{ password: 'max:10' }The field under validation must be less than or equal to the given max value.
min{ password: 'min:6' }The field under validation must have the given min value.
numeric{ age: 'numeric' }The field under validation must be numeric.
required{ name: 'required' }The field under validation must be present and not empty.
string{ name: 'string' }The field under validation must be a string.

FAQs

Package last updated on 29 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc