New issue

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

如果规则返回值为undefined,则继续验证下一个规则 #146

Closed
niceue opened this Issue Jul 21, 2014 · 0 comments

Comments

Projects
None yet
1 participant
@niceue
Copy link
Owner

niceue commented Jul 21, 2014

当某个规则没有返回值,或者返回值为undefined的时候(注意:不存在的规则也相当于是undefined),niceValidator将继续验证下一个规则(如果有的话)。

如下场景,你可以用来做密码强度检测。
其中,strength 规则只需要作为回调存在,用来处理密码强度的检测以及提示。

<input type="password" name="pwd" data-rule="required;password;strength">

同时,这还是一种智能容错机制。如下示例,undefinedRule 并没有被定义,但是也不会报错。

<input type="text" name="user" data-rule="required;undefinedRule">

@niceue niceue added this to the 0.8.0 milestone Jul 21, 2014

@niceue niceue closed this in fc3391b Jul 21, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment