Skip to content

Commit

Permalink
Small validation bug fix - now validation.installValidationmethods() …
Browse files Browse the repository at this point in the history
…passes the pouchdb-server test suite.
  • Loading branch information
marten-de-vries committed Jul 7, 2014
1 parent e2ddb04 commit 2dbd1df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function doValidation(db, newDoc, options, callback) {
//CouchDB does the checking for itself. Validate succesful.
return Promise.resolve();
}
if ((newDoc._id || "").indexOf("_design/") === 0) {
if (String(newDoc._id).indexOf("_design/") === 0) {
//a design document -> always validates succesful.
return Promise.resolve();
}
Expand Down Expand Up @@ -168,7 +168,7 @@ exports.validatingPut = function (doc, options, callback) {
var promise = doValidation(args.db, doc, args.options).then(function () {
return methods(args.db).put(doc, args.options);
});
nodify(promise, callback);
nodify(promise, args.callback);
return promise;
};

Expand All @@ -179,7 +179,7 @@ exports.validatingPost = function (doc, options, callback) {
var promise = doValidation(args.db, doc, args.options).then(function () {
return methods(args.db).post(doc, args.options);
});
nodify(promise, callback);
nodify(promise, args.callback);
return promise;
};

Expand All @@ -190,7 +190,7 @@ exports.validatingRemove = function (doc, options, callback) {
var promise = doValidation(args.db, doc, args.options).then(function () {
return methods(args.db).remove(doc, args.options);
});
nodify(promise, callback);
nodify(promise, args.callback);
return promise;
};

Expand Down Expand Up @@ -223,7 +223,7 @@ exports.validatingBulkDocs = function (bulkDocs, options, callback) {
}).then(function (insertedDocs) {
return done.concat(insertedDocs);
});
nodify(allValidationsPromise, callback);
nodify(allValidationsPromise, args.callback);
return allValidationsPromise;
};

Expand All @@ -245,7 +245,7 @@ var vpa = function (docId, attachmentId, rev, attachment, type, options, callbac
//save the attachment
return methods(args.db).putAttachment(docId, attachmentId, rev, attachment, type);
});
nodify(promise, callback);
nodify(promise, args.callback);
return promise;
};
exports.validatingPutAttachment = vpa;
Expand All @@ -262,7 +262,7 @@ var vra = function (docId, attachmentId, rev, options, callback) {
//remove the attachment
return methods(args.db).removeAttachment(docId, attachmentId, rev);
});
nodify(promise, callback);
nodify(promise, args.callback);
return promise;
};
exports.validatingRemoveAttachment = vra;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pouchdb-validation",
"version": "1.1.3",
"version": "1.1.5",
"main": "index.js",
"description": "A PouchDB plug-in that allows you to re-use your CouchDB validate_doc_update functions on the client side.",
"repository": {
Expand Down

0 comments on commit 2dbd1df

Please sign in to comment.