Created
November 2, 2017 06:14
-
-
Save QETHAN/f0c3f40361b4b01cb42f4c5cce9610d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const checkIp = (rule, value, callback) => { | |
if (!value) { | |
return callback(new Error(`服务器IP不能为空`)) | |
} | |
let regIp = /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/ | |
let status = regIp.test(value) | |
if (!status) { | |
callback(new Error('IP格式错误')) | |
} else { | |
callback() | |
} | |
} | |
const checkBlank = (rule, value, callback) => { | |
if (!value) { | |
let field = rule.field === 'username' ? '用户名' : '密码' | |
return callback(new Error(`${field}不能为空`)) | |
} else { | |
callback() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment