New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

basic-validation

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-validation

This module applies basic validation on JSON data in dot cascade notation.

latest
Source
npmnpm
Version
1.0.7
Version published
Maintainers
1
Created
Source

Synopsis

This module applies basic validation on JSON data in dot cascade notation.

Code Example

var validation = require('basic-validation');

var againstThis = {
    title: validation.string().required(),
    author: validation.string().allow(['']),
    cost: validation.number().valid([1200, 1300]),
    publishers: validation.array().items(validation.object().keys({
        name: validation.string()
    }))
};

var validateThis = {
    title: "Conjuring",
    author: "MR X",
    cost: 1200
};


validation.validate(validateThis, againstThis, function(err, result) {
	console.log("err :-", err);
	console.log("result :-", result);
});


/*output will be
	err:- null
	result:- { title: 'Conjuring', author: 'MR X', cost: 1200 }
*/

var againstThis = {
    title: validation.string().required(),
    author: validation.string().allow(['']),
    cost: validation.number().valid([1200, 1300]),
    publishers: validation.array().items(validation.object().keys({
        name: validation.string()
    }))
};

var validateThis = {
    author: "MR X",
    cost: 1200
};


validation.validate(validateThis, againstThis, function(err, result) {
	console.log("err :-", err);
	console.log("result :-", result);
});


/*output will be
	err:- title is required 
	result:- undefined

*/

Motivation

The module was created to apply validation on old node version where some functionality of 'joi' was not compatible;

FAQs

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