We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
例子:
猜测是不是 https://github.com/yiminghe/async-validator/blob/master/src/validator/enum.js#L23 这里的问题
The text was updated successfully, but these errors were encountered:
if (validate) { if (isEmptyValue(value) && !rule.required) { return callback(); } rules.required(rule, value, source, errors, options); if (value) { rules[ENUM](rule, value, source, errors, options); } }
@yiminghe 我觉得没有必要第二次去判断value,因为上面已经对value做了一次验证,这里直接调用即可:
if (validate) { if (isEmptyValue(value) && !rule.required) { return callback(); } rules.required(rule, value, source, errors, options); rules[ENUM](rule, value, source, errors, options); }
而且在rules[ENUM]中再次使用value的时候,也只是作为参数:
function enumerable(rule, value, source, errors, options) { rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : []; if (rule[ENUM].indexOf(value) === -1) { errors.push(util.format(options.messages[ENUM], rule.fullField, rule[ENUM].join(', '))); } }
Sorry, something went wrong.
fix [yiminghe#52]
ff1310b
enum 模式中value值可以为0、false等
No branches or pull requests
例子:
猜测是不是 https://github.com/yiminghe/async-validator/blob/master/src/validator/enum.js#L23 这里的问题
The text was updated successfully, but these errors were encountered: