New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js-validate

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-validate

Functional, extensible, input validation. Make sure the value you receive is EXACTLY what you expect.

  • 0.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

js-validate

Functional, extensible, input validation. Make sure the value you receive is EXACTLY what you expect.

Getting Started

Installation
npm install js-validate
Quick Use
```node var validator = require('js-validate'); ```
var validate = validator.start();
Validate against a single rule:
validate('123', 'min-length 2');  //--> true
Validate against multiple rules:
validate('123', ['min-length 2', 'number']);  //-->true
Built-in Rules
- alpha - alphanumeric - boolean **NEW** - capitals (counts capital characters) - ends-with - equals - length - max - max-length - min - min-length - number (isNumber) ***Altered Rule*** - numbers (Number Characters) - numeric (consists of numerical digits) **NEW** - specials (Special Characters) - starts-with
Create a validator (rule) group:
validator.group({
  'account-number': [
    'alphanumeric',
    'min-length 7',
    'starts-with 000-',
    'ends-with -00'
  ]
});
Validate against a group of rules:
validate('000-KLJ8989123-00', 'account-number');  //--> true
Create a custom rule:
validator.rules({
  isOkay: function(input) {
    return input === 'ok';
  }
});
Keep this in mind when creating custom rules:
  • Validator rules must return a pure boolean (true | false)
  • The first parameter must be the user input
  • Unlimited additional parameters are supported
  • Custom rules are added to the default rule list
  • Custom rules may be used in conjunction with defaults in rule groups

Keywords

FAQs

Package last updated on 18 Jun 2016

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