check-data
Advanced tools
Comparing version 1.3.8 to 1.3.9
42
index.js
@@ -92,20 +92,28 @@ "use strict"; | ||
// 包含字符串 | ||
if (options.contain) { | ||
if (options.contain === Number) { | ||
if (data.search(/\d+/) === -1) { | ||
return `${key}参数必须包含数字` | ||
} | ||
// 包含 | ||
if (options.in) { | ||
let result = options.in.indexOf(data) | ||
if (result === -1) { | ||
return `${key}参数可选值必须为:${options.in}` | ||
} | ||
} | ||
// 不包含 | ||
if (options.noContain) { | ||
if (options.noContain === Number) { | ||
if (data.search(/\d+/) > -1) { | ||
return `${key}参数不能包含数字` | ||
} | ||
} | ||
} | ||
// 包含字符串 | ||
// if (options.contain) { | ||
// if (options.contain === Number) { | ||
// if (data.search(/\d+/) === -1) { | ||
// return `${key}参数必须包含数字` | ||
// } | ||
// } | ||
// } | ||
// // 不包含 | ||
// if (options.noContain) { | ||
// if (options.noContain === Number) { | ||
// if (data.search(/\d+/) > -1) { | ||
// return `${key}参数不能包含数字` | ||
// } | ||
// } | ||
// } | ||
// 正则表达式 | ||
@@ -142,6 +150,6 @@ if (options.reg) { | ||
// 包含 | ||
if (options.contain) { | ||
let result = options.contain.indexOf(data) | ||
if (options.in) { | ||
let result = options.in.indexOf(data) | ||
if (result === -1) { | ||
return `${key}参数可选值必须为${typeof data}类型${options.contain}` | ||
return `${key}参数可选值必须为:${options.in}` | ||
} | ||
@@ -148,0 +156,0 @@ } |
{ | ||
"name": "check-data", | ||
"version": "1.3.8", | ||
"version": "1.3.9", | ||
"description": "JS数据验证器", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,3 +20,3 @@ let Verify = require('../index') | ||
"lala": 168, | ||
"kaka": 2 | ||
"kaka": "3" | ||
}, | ||
@@ -70,3 +70,3 @@ "email": "xxx@xx.xx" | ||
"type": Number, | ||
"contain": [1, 2, 3], | ||
"in": [1, 2, 3], | ||
"allowNull": true | ||
@@ -73,0 +73,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21135
541