Permalink
Browse files

iterate arguments properly

  • Loading branch information...
1 parent 1eb0e51 commit 0b763a89d44ddade084aee30cef6dbafc1f35b70 @aheckmann aheckmann committed Feb 8, 2012
Showing with 10 additions and 5 deletions.
  1. +10 −5 lib/schematype.js
View
@@ -160,13 +160,18 @@ SchemaType.prototype.get = function (fn) {
SchemaType.prototype.validate = function (obj, error) {
if ('function' == typeof obj) {
- this.validators.push([obj, error]);
+ this.validators.push([obj, error]);
+ return this;
}
- else {
- for (var i in arguments) {
- this.validators.push([arguments[i].validator, arguments[i].msg]);
- }
+
+ var i = arguments.length
+ , arg
+
+ while (i--) {
+ arg = arguments[i];
+ this.validators.push([arg.validator, arg.msg]);
}
+
return this;
};

0 comments on commit 0b763a8

Please sign in to comment.