/
package.json
37 lines (37 loc) · 5.63 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{
"author": {
"name": "doublespout",
"email": "snoopyxdy@163.com",
"url": "http://snoopyxdy.blog.163.com"
},
"name": "hvalidator",
"description": "HIgh performance nodejs validator moudle with C++.",
"keywords": [
"validator",
"high performance",
"c++",
"node",
"validate"
],
"version": "0.3.5",
"url": "https://github.com/DoubleSpout/node-hvalidator",
"homepage": "https://github.com/DoubleSpout/node-hvalidator",
"repository": {
"type": "git",
"url": "https://github.com/DoubleSpout/node-hvalidator.git"
},
"main": "index.js",
"engines": {
"node": ">=0.8.5"
},
"scripts": {
"install": "node-gyp rebuild"
},
"gypfile": true,
"readme": "\r\n\r\n# node-hvalidator —— HIgh performance nodejs validator moudle with C++.\r\n\r\n目前正在编码中...\r\n\r\nCurrently coding...\r\n\r\nIn windows regex are different\r\n\r\n##Install\r\n\r\n npm install hvalidator\r\n\r\n var hv = require('hvalidator')\r\n\r\n##API(isxxx function return bool)\r\n\r\n \r\n hv.is(arg1,regexp);//arg1:string or number; arg:regexp\r\n\r\n hv.isArray(arg1);//arg1:array will be true, others will be false;\r\n\r\n hv.isRegExp(arg1);//arg1:regexp will be true, others will be false;\r\n\r\n hv.isNumber(arg1);//arg1:number will be true, others will be false;\r\n\r\n hv.isPositive(arg1);//arg1:the number>0 will be true, others will be false;\r\n\r\n hv.isInt(arg1);//arg1:the int will be true, others will be false;\r\n\r\n hv.notEmpty(arg1);//arg1:string or number; others will be false; this function can't trim;\r\n\r\n hv.isDate(arg1);//arg1:the date will be true, others will be false;\r\n\r\n hv.isString(arg1);//arg1:the string will be true, others will be false;\r\n\r\n hv.isLowercase(arg1);//arg1:string and lowercasen will be true, others will be false;\r\n\r\n hv.isUppercase(arg1);//arg1:string and uppercase will be true, others will be false;\r\n\r\n hv.isIn(arg1,contain);//arg1 is string or number; arg2 is array or string\r\n\r\n hv.isLen(arg1,min,max);//arg1:string or number or array;\r\n\r\n hv.isEmail(arg1);//arg1:string match for email\r\n\r\n hv.isUrl(arg1);//arg1:string match for url\r\n\r\n hv.isIp(arg1);//arg1:string match for ipaddr\r\n \r\n\r\n##Example:\r\n\r\n\teq(hv.is('aaaa11@aaaa.com',/[_\\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\\.)+[a-z]{2,3}$/), true);\r\n\t//in windows must be double '\\',like /[_\\\\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\\\\.)+[a-z]{2,3}$/\r\n\teq(hv.is('1234567',/\\d+/),false);\r\n\t//in windows must be double '\\',like /\\\\d+/\r\n\teq(hv.is('1',/^1$/),true);\r\n\teq(hv.is('11aa',/\\d/),false);\r\n\r\n\teq(hv.isArray([]),true)\r\n\teq(hv.isArray(123),false)\r\n\r\n\teq(hv.isRegExp(/\\d/),true)\r\n\teq(hv.isRegExp(123),false)\r\n\r\n\teq(hv.isNumber(123),true)\r\n\teq(hv.isNumber('abc'),false)\r\n\r\n\teq(hv.isPositive(122.2),true)\r\n\teq(hv.isPositive(-1),false)\r\n\r\n\teq(hv.isInt(123),true)\r\n\teq(hv.isInt(123.2),false)\r\n\r\n\teq(hv.notEmpty(\"aa\"),true)\r\n\teq(hv.notEmpty(\"\"),false)\r\n\r\n\teq(hv.isDate(new Date()),true)\r\n\teq(hv.isDate(12321312),false)\r\n\r\n\teq(hv.isString('abc'),true)\r\n\teq(hv.isString(123),false)\r\n\r\n\teq(hv.isLowercase('abc'),true)\r\n\teq(hv.isLowercase('a123A1'),false)\r\n\r\n\teq(hv.isUppercase('ABC'),true)\r\n\teq(hv.isUppercase('a123A1'),false)\r\n\r\n\r\n\teq(hv.isIn('ABC','ABCDEFG'),true)\r\n\teq(hv.isIn('AAA','ABCDEFT'),false)\r\n\teq(hv.isIn(123,'123456789'),true)\r\n\teq(hv.isIn(123,'ABCDEFT'),false)\r\n\r\n\teq(hv.isIn('ABC',['ABCDEFG','123','234','ABC']),true)\r\n\teq(hv.isIn('AAA',['ABCDEFG','123','234','abc']),false)\r\n\teq(hv.isIn(234,['ABCDEFG','123','234','abc']),true)\r\n\teq(hv.isIn(123,['ABCDEFG','567','234','abc']),false)\r\n\r\n\teq(hv.isLen('ABC',1,5),true)\r\n\teq(hv.isLen('aaaaaaaa',1,5),false)\r\n\teq(hv.isLen(5,1,5),true)\r\n\teq(hv.isLen(6,1,5),false)\r\n\teq(hv.isLen([1,2,3],1,5),true)\r\n\teq(hv.isLen([],1,5),false)\r\n\r\n\teq(hv.isEmail('sfsd@fsfas.com'),true);\r\n\teq(hv.isEmail('sfsd@@@fsfas.com'),false);\r\n\r\n\teq(hv.isUrl('http://bbs.csdn.net/topics/270080323/'),true);\r\n\teq(hv.isUrl('fasfdfdas'),false);\r\n\r\n\teq(hv.isIp('10.10.10.10'),true);\r\n\teq(hv.isIp('12.12.12.10.10'),false);\r\n \r\n##performance\r\n \r\n see ./benchmark/benchmark.js\r\n\r\n result is:\r\n\r\n nodejs: 8ms\r\n\r\n c++: 1ms\r\n\r\n\r\n## 授权协议\r\n\r\n基于MIT协议发布:\r\n\r\n```\r\nCopyright (c) 2012 Lei Zongmin(吴中骅) <snoopyxdy@gmail.com>\r\n\r\nThe MIT License\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining\r\na copy of this software and associated documentation files (the\r\n\"Software\"), to deal in the Software without restriction, including\r\nwithout limitation the rights to use, copy, modify, merge, publish,\r\ndistribute, sublicense, and/or sell copies of the Software, and to\r\npermit persons to whom the Software is furnished to do so, subject to\r\nthe following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be\r\nincluded in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n```",
"_id": "hvalidator@0.2.1",
"dist": {
"shasum": "cdbc2648862dcaeb33a5cfc5eeddc02f0afb6428"
},
"_from": "hvalidator"
}