
Security News
NIST Under Federal Audit for NVD Processing Backlog and Delays
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Critiq is a simple parameter validator useful for API building.
npm install critiq --save
// CommonJS
var Critiq = require('critiq')
// EcmaScript
import Critiq from 'critiq'
Indicate the fields to validate -- Fields should be in the data object
12345
not "12345"
- ['string','integer']
- ['string','function']
- ['string','object']
- ['string','array']
- ['integer','function']
- ['integer','object']
- ['integer','array']
- ['array','function']
- ['array','object']
- ['object','function']
- ['function']
- ['array']
Strictly solo Datatype Validations
Example String ( min and max are allowed )
Critiq.validate(['string'], 'asdfasdf', function(err,result){})
Example Integer ( min and max are allowed )
Critiq.validate(['integer'], 23554667, function(err,result){})
Example Object ( min and max are forbidden )
Critiq.validate(['object'], {key:'value'}, function(err,result){})
Example Array ( min and max are forbidden )
Critiq.validate(['array'], [1,'two',3,4,'five'], function(err,result){})
Example Function ( min and max are forbidden )
Critiq.validate(['function'], function(){}, function(err,result){})
// Example String and Number
Critiq.validate(['string','number'], '3456547', function(err,result){})
// Example String and alphaNum
Critiq.validate(['string','alphaNum'], 'aBcd3456547', function(err,result){})
// Example String and Number
Critiq.validate(['string','alphaber'], 'abcdEfgHij', function(err,result){})
Catch the Error and Result
Critiq.validate(['string'], 'asdfasdf', function(err,result){
if(err){
console.log(err);
return
}
console.log('Hooray data is valid!')
console.log(result)
})
PARAMETERS
Below is an example
var payload = {
email:'rhomnickcoloma@gmail.com',
username:'user123',
accountNumber: 1478248799308456,
callback:function(){},
education:{
highschool:'name of highschool',
college:'name of college school',
awards:{
award1:'Award1 name',
award2:'Award2 name',
award3:'Award3 name',
}
},
friends:['tina','james']
}
var config = {
email:['string','email','required'],
username:['string','alphaNum','min-5','max-15'],
accountNumber: ['integer','min-10','max-16'],
callback: ['function'],
education: ['object', {
highschool: ['string','min-500'], // has error for testing
college: ['string','min-5'],
awards:['object',{
award1:['number'] //has error for testing
}]
}],
friends: ['array']
}
Critiq.validate(config, payload, function(err,result){
if(err){
console.log(err);
return
}
console.log('Hooray! Everything is validated')
console.log(result)
})
email me at
rhomnickcoloma@gmail.com
Copyright (c) 2016, Rhomnick B. Coloma rhomnickcoloma@gmail.com
Permission to use, copy, modify, and/or distribute this software for any with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
FAQs
Critiq is a simple data validator useful for API building.
The npm package critiq receives a total of 1 weekly downloads. As such, critiq popularity was classified as not popular.
We found that critiq demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.
Security News
TypeScript Native Previews offers a 10x faster Go-based compiler, now available on npm for public testing with early editor and language support.