Commit 6b490591 authored by huhao's avatar huhao

添加maxlength校验

parent 794efb5d
...@@ -445,6 +445,12 @@ function notEmpty(value, message) { ...@@ -445,6 +445,12 @@ function notEmpty(value, message) {
validate(!!value, message); validate(!!value, message);
} }
function maxlength(value, expected, message) {
if (value) {
validate(value.length <= expected, message);
}
}
/** /**
* App扩展 * App扩展
*/ */
...@@ -475,7 +481,8 @@ module.exports = { ...@@ -475,7 +481,8 @@ module.exports = {
validator: { // 数据校验工具 validator: { // 数据校验工具
gt, gt,
notEmpty, notEmpty,
equal equal,
maxlength
}, },
extendApp // koa扩展入口 extendApp // koa扩展入口
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment