check-data
Advanced tools
Comparing version 1.3.6 to 1.3.7
21
index.js
@@ -66,14 +66,2 @@ "use strict"; | ||
// 包含 | ||
else if (options.contain) { | ||
// 对Number类型特殊照顾,将字符串转数值 | ||
if (options.type === Number) { | ||
data = Number(data) | ||
} | ||
let result = options.contain.indexOf(data) | ||
if (result === -1) { | ||
return `${key}参数值不包含${typeof data}:${data}` | ||
} | ||
} | ||
// type为JS内置数据类型 | ||
@@ -98,2 +86,3 @@ else if (typeof options.type === 'function') { | ||
} | ||
if (options.maxLength) { | ||
@@ -153,2 +142,10 @@ if (data.length > options.maxLength) { | ||
// 包含 | ||
if (options.contain) { | ||
let result = options.contain.indexOf(data) | ||
if (result === -1) { | ||
return `${key}参数可选值必须为${typeof data}类型${options.contain}` | ||
} | ||
} | ||
// 数值转布尔值 | ||
@@ -155,0 +152,0 @@ if (options.conversion) { |
{ | ||
"name": "check-data", | ||
"version": "1.3.6", | ||
"version": "1.3.7", | ||
"description": "JS数据验证器", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,3 +20,3 @@ let Verify = require('../index') | ||
"lala": 168, | ||
"kaka": 595959 | ||
"kaka": 2 | ||
}, | ||
@@ -70,2 +70,3 @@ "email": "xxx@xx.xx" | ||
"type": Number, | ||
"contain": [1, 2, 3], | ||
"allowNull": true | ||
@@ -72,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
20832
534