Permalink
Browse files

fix isRequired setting of SchemaType

  • Loading branch information...
aheckmann committed Mar 19, 2011
1 parent 4c6e45a commit 25d729eb412094663a46ace70682d447cfe5ea71
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/mongoose/schematype.js
@@ -134,14 +134,15 @@ SchemaType.prototype.required = function(required){
return self.checkRequired(v);
}
- this.isRequired = true;
-
if (false === required){
+ this.isRequired = false;
this.validators = this.validators.filter(function(v){
return v[0] !== checkRequired;
});
- } else
+ } else {
+ this.isRequired = true;
this.validators.push([checkRequired, 'required']);
+ }
return this;
};

0 comments on commit 25d729e

Please sign in to comment.