Skip to content

Commit b79b55e

Browse files
committed
fixed len() tips
1 parent 821da0d commit b79b55e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/validate.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,13 @@ Validator.prototype.isLength = function(min, max, tip) {
156156
max = v.isInt(max) ? max :-1;
157157
this.exist(tip);
158158
if (this.goOn) {
159-
if (this.value.length<min || -1!=max&&this.value.length>max) {
160-
this.addError(tip || this.key + "'s length equal or great than " + min + (-1 == typeof max ? " and equal or less than " + max + "." : "."));
159+
if(this.value.length<min) {
160+
this.addError(tip || this.key + "'s length must equal or great than " + min+".");
161+
return this;
162+
}
163+
if (-1!=max&&this.value.length>max) {
164+
this.addError(tip || this.key + "'s length must equal or less than " + max + ".");
165+
return this;
161166
}
162167
}
163168
return this;

0 commit comments

Comments
 (0)