Home > connect-validator

connect-validator

Connect-validator is a project mainly written in JavaScript, it's free.

connect插件,用来作字段验证

connect验证插件

var Validate = require('./connect-validator').Validate;

//首先 new Validate(),之后调用其check方法, //返回的结果是一个connect插件 //new Validate().check({ // name: function(){ // this.msg = "Invalid username!"; // this.isChinese(); // } //}) app.get('/book',new Validate().check({ name: function(){ this.msg = "IP地址不对劲哦!"; this.isIP(); //this.isNumeric(); } }), function(req,res){ if(req.errors){ log(req.errors); res.send('<font color="red">'+req.errors+''); } else res.send('正确'); });

Previous:HelloWorld