apply update options without save for pre-validation - mongoosejs

In any webapp i press a plus button and a value will be increased. When i hit the button fast the validation does not work, cause the validations does not prevent (excepted behavior, the value is not out of the validations range). But the value will be setted down further, cause the rest of the reqeust will be submitted.

Important: the update options are dynamically (for instance $inc or $set).

Current Code

module.model.update({ _id: id }, options /* are dynamic */, { safe: true }, function (err, updatedDocument) {
    if (err) return respond(400, err);

    module.model.findOne({ _id: id }, function (err, foundDocument) {
        if (err) return respond(400, err);

        foundDocument.validate(function (err) {
            if (err) return respond(400, err);

            return respond(200, foundDocument); // callback method
        });
    });
});

First guess to prevent the problem

module.model.findOne({ _id: id }, function (err, foundDocument) {

    foundDocument.set(options);

    foundDocument.validate(function (err) {
        if (err) return respond(400, err);

        foundDocument.save(function (err, savedDocument) {
            if (err) return respond(400, err);

            return respond(200, doc);
        });
    });
});

...then the save just will preformed when the validation is valid.

But there is a porblem: The set method does not support $inc or other pseudo setters, or does it?

I saw the possibility to use the constructor of the update function (Show Code), but i don't know how to use it: this.constructor.update.apply(this.constructor, args);

Do you have any good practise for this problem ?

The solution was to create a customized version for $inc. What i've done is to replace the set method of mongoosejs.

This is now extendable, but a quiet custom way to validate before an update. When someone have another solution. Post it please.

module.model.findOne({ _id: id }, function (err, foundDocument) {

    for(var optionsProp in options) {
        if(optionsProp === '$inc') {
            for(var incProp in options[optionsProp]) {
                foundDocument[incProp] += options[optionsProp][incProp];
            }
        }
    }

    foundDocument.validate(function (err) {
        if (err) return respond(400, err);

        foundDocument.save(function (err, savedDocument) {
            if (err) return respond(400, err);

            return respond(200, savedDocument);
        });
    });
});