Skip to content
This repository was archived by the owner on Nov 27, 2018. It is now read-only.
This repository was archived by the owner on Nov 27, 2018. It is now read-only.

trying to use express-form in a function (not inline) #1

@warnero

Description

@warnero

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions