You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
I have this defined in an external file
exports.validateObject = function(req) {
return form(
form.field("bookmark_url").trim().required().isUrl(),
form.field("bookmark_title").trim(),
form.field("bookmark_tags").trim(),
form.field("bookmark_description").trim()
);
}
I'm then using it in my app.js like this:
app.post('/notebooks/:notebookId/bookmark', route.validateObject, route.saveObject);
It gets to the validateObject function but never calls my route method. Hoping you can help shed some light on how to use it this way as I don't see any examples that allow you to separate your validation from where you define your routing. I have also verified that all the fields are coming through to the validateObject method by looking at the req.body.
The text was updated successfully, but these errors were encountered:
Friend helped me out and I managed to fix it by doing this instead
exports.validateObject = form(
form.field("bookmark_url").trim().required().isUrl(),
form.field("bookmark_title").trim(),
form.field("bookmark_tags").trim(),
form.field("bookmark_description").trim()
);
Would be good if you could add an example showing this for others.
I have this defined in an external file
exports.validateObject = function(req) {
return form(
form.field("bookmark_url").trim().required().isUrl(),
form.field("bookmark_title").trim(),
form.field("bookmark_tags").trim(),
form.field("bookmark_description").trim()
);
}
I'm then using it in my app.js like this:
app.post('/notebooks/:notebookId/bookmark', route.validateObject, route.saveObject);
It gets to the validateObject function but never calls my route method. Hoping you can help shed some light on how to use it this way as I don't see any examples that allow you to separate your validation from where you define your routing. I have also verified that all the fields are coming through to the validateObject method by looking at the req.body.
The text was updated successfully, but these errors were encountered: