🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

api-validate

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-validate

request params validate

Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
5
400%
Maintainers
1
Weekly downloads
 
Created
Source

api-validate

简单的参数验证,验证接口端收到的数据

   var v = require('api-validate');
   var rule = {
     name : {type:'string',match:/tjay/,required:true,msg:'name error'},
	 age : {type:'number',min:1,max:130,required:true,msg:'age error'}//...
   }
   
   v.validate(rule,{
     name:'tjay',
	 age:20
   });// return => []
   
    v.validate(rule,{
     name:'tjay1',
	 age:-1
   });// return => ['name error','age error']

Keywords

params

FAQs

Package last updated on 11 Dec 2015

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