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

nosix

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nosix

Input validation module

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

nosix.js

nosix.js abstracts input validation, making it easier and straighforward for you to validate any type of input.

You run nosix by providing a list of validator functions and an input. nosix will test the input against the validators and return the results.

If the input fails to pass one of more validators, the result will be an object with the validation errors. You can initialize nosix.js with a set of validators and add/remove validators at run time.

By default, Nosix works async. You may also run Nosix in a sync mode.

Instalation

npm install nosix

How to use nosix.js

const nosix = require('nosix');

const fn1 = input => typeof input == 'string' ? true : `${input} must be a string`;
const fn2 = input => input != '' ? true : `${input} cannot be empty`;

const stringInput = "a random string";
const objInput = { random: "object" };

// validate async
nosix.validate(stringInput, [fn1, fn2], err => {
  if(!err) console.log('validation OK'); // validation OK
});

// validate sync
const err = validateSync(objectInput, [fn1, fn2]);
console.log(err); // [ '[Object object] must be a string' ] 

The returned object err is null if there was no validation errors. Otherwise the returned value is an array with all validation errors.

License:

MIT © Gonçalo Pestana

Keywords

FAQs

Package last updated on 13 Apr 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