check-data
Advanced tools
Comparing version 1.7.6 to 1.7.7
@@ -250,2 +250,7 @@ "use strict" | ||
// 预定义数据模型表达式 | ||
Validator.schema = function (name, expression) { | ||
} | ||
// 验证类型扩展 | ||
@@ -252,0 +257,0 @@ Validator.use = extend |
{ | ||
"name": "check-data", | ||
"version": "1.7.6", | ||
"version": "1.7.7", | ||
"description": "JS对象验证器", | ||
@@ -12,3 +12,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"filter-null": "^0.1.1", | ||
"filter-null": "^1.2.0", | ||
"validator": "^8.0.0" | ||
@@ -15,0 +15,0 @@ }, |
@@ -9,3 +9,3 @@ ### Installation | ||
let { error, data, $, ... } = Validator(data, options, constructor) | ||
let { error, data } = Validator(data, options, customize) | ||
@@ -18,13 +18,13 @@ ### 输入 | ||
* `export` *Objcte* - 自定义数据导出方法,使用验证后的数据创建新的数据结构,通过方法中的this和第一个函数参数提取验证数据(可选) | ||
* `customize` *Objcte* - 自定义数据导出对象(可选) | ||
* `customize.$` *Function* - 自定义数据导出方法,使用验证后的数据创建新的数据结构,this和函数第一个参数指向已验证数据 | ||
### 输出 | ||
* `error` *String* - 验证失败时返回的错误信息,包含错误的具体位置,仅用于验证失败时的错误定位 | ||
* `error` *String* - 验证失败时返回的错误信息,包含错误的具体位置信息,仅供开发者调试使用 | ||
* `msg` *String* - 验证失败时返回的错误信息,相对于error对用户更加友好,可用于客户端显示 | ||
* `data` *Objcte* - 经过验证、处理后导出数据(带空值过滤,用于剔除对象中的空数组、空字符串、undefind、null等无效数据) | ||
* `${name}` *Objcte* - 由export对象中构造方法导出的数据,命名与export中函数名一致(带空值过滤) | ||
* `msg` *String* - 验证失败后返回的错误信息,相对于error而言,msg对用户更加友好,可直接在客户端显示 | ||
@@ -75,4 +75,6 @@ | ||
> 仅支持类型验证 | ||
* `minLength` *Number* - 限制字符串最小长度 | ||
* `maxLength` *Number* - 限制字符串最大长度 | ||
#### Object | ||
@@ -254,3 +256,3 @@ | ||
# 验证表达式 | ||
let { error, data, filter } = Validator(json, | ||
let { error, data } = Validator(json, | ||
{ | ||
@@ -257,0 +259,0 @@ "username": { |
@@ -48,3 +48,2 @@ "use strict" | ||
let { error, data } = Validator(json, | ||
@@ -135,12 +134,2 @@ { | ||
"arr": Array, | ||
"test": { | ||
"type": Array, | ||
method(data) { | ||
if (data.length) { | ||
return 1 | ||
} else { | ||
return 6 | ||
} | ||
} | ||
} | ||
}, | ||
@@ -161,2 +150,11 @@ { | ||
} | ||
}, | ||
where() { | ||
return { | ||
"email": undefined, | ||
"integral": '', | ||
"t": 888, | ||
"j": undefined, | ||
"c": '8', | ||
} | ||
} | ||
@@ -172,2 +170,3 @@ } | ||
console.log(data) | ||
console.log(data.filter) | ||
console.log(data.filter) | ||
console.log(data.where) |
27109
660
334
+ Addedfilter-null@1.2.0(transitive)
- Removedfilter-null@0.1.1(transitive)
Updatedfilter-null@^1.2.0