Validation on user inputs with MongoDB and mongoose?
<p>I would an unified method to validate my schemas assuming a user input, so not only apply the built-in validation on save/update, but also on find(), etc..</p>

<pre><code>var User = mongoose.model("User", new Schema({
    name:   {type: String, minlength: 5, maxlength: 128, required: true, unique: true});
}));
</code></pre>

<p>What I want is to run validators every time before I run the queries with mongoose, to assure that the user inputs comply with the global schema rules.</p>

<p>Something like that in my route:</p>

<pre><code>var username = $.get["username"], //An input from GET querystring

User = mongoose.model("User");

User.validate({name: username}, function(err) {
    if (err) return console.log("not valid input"); //i.e. too short

    //run query if valid
});
</code></pre>

<p>Is there a plugin <em>(assumed that I'm not using Express)</em> or maybe other already included in mongoose for that?</p>