Validate object against Mongoose schema without saving as a new document
<p>I'm trying to validate some data that will be inserted into a new document, but not before a lot of other things need to happen. So I was going to add a function to the static methods that would hopefully validate objects in an array against he model schema.</p>

<p>Heres the code thus far:</p>

<pre class="lang-js prettyprint-override"><code>module.exports = Mongoose =&gt; {
    const Schema = Mongoose.Schema

    const peopleSchema = new Schema({
        name: {
            type: Schema.Types.String,
            required: true,
            minlength: 3,
            maxlength: 25
        },
        age: Schema.Types.Number
    })

    /**
     * Validate the settings of an array of people
     *
     * @param   {array}     people  Array of people (objects)
     * @return  {boolean}
     */
    peopleSchema.statics.validatePeople = function( people ) {
        return _.every(people, p =&gt; {
            /**
             * How can I validate the object `p` against the peopleSchema
             */
        })
    }

    return Mongoose.model( 'People', peopleSchema )
}
</code></pre>

<p>So the <code>peopleSchema.statics.validatePeople</code> is where I'm trying to do the validation. I have read through mongooses <a href="http://mongoosejs.com/docs/validation.html" rel="noreferrer">validation</a> documents, but it doesn't state how to validate against a model without saving the data.</p>

<p>Is this possible?</p>

<h2>Update</h2>

<p>One of the answers on here pointed me towards the proper validation method, which seems to work, but now its throwing an <code>Unhandled rejection ValidationError</code>. </p>

<p>Heres the static method used to validate data (<strong>without</strong> inserting it)</p>

<pre class="lang-js prettyprint-override"><code>peopleSchema.statics.testValidate = function( person ) {
    return new Promise( ( res, rej ) =&gt; {
        const personObj = new this( person )

        // FYI - Wrapping the personObj.validate() in a try/catch does NOT suppress the error
        personObj.validate( err =&gt; {
            if ( err ) return rej( err )

            res( 'SUCCESS' )
        } )
    })
}
</code></pre>

<p>Then heres me testing it out:</p>

<pre class="lang-js prettyprint-override"><code>People.testValidate( { /* Data */ } )
    .then(data =&gt; {
        console.log('OK!', data)
    })
    .catch( err =&gt; {
        console.error('FAILED:',err)
    })
    .finally(() =&gt; Mongoose.connection.close())
</code></pre>

<p>Testing it out with data that doesnt follow the schema rules will throw the error, and as you can see, I try to catch it, but it doesnt seem to work.</p>

<p><strong>P.S.</strong> Im using Bluebird for my promises</p>