Formal-mongoose
Formal + Mongoose = DRY! Simple solution to define a form with validation (and more) from a mongoose schema.
Example
var Form = model = mongoose; var form = model 'name.*' 'email'; form; form; form;
Install
npm install formal-mongoose --save
Summary
Extend formal
to provides fast and easy way to define a form from an existing schema. The best way to don't repeat yourself!
API
For the inherited prototype see the Formal API.
new Form(schema:Object|String, fields:Array, options:Object):instance
schema
mongoose schema or model
fields
array of strings path to import from the mongoose schema
options
object of options identical to Formal
var Form = ;var form = mongoose 'username' 'pasword';
For connect and express the alternative factory method can be used as a quick helper to create a new instance and return form.middleware() to monkey patch the request and response object.
app;
form.addPath(path:String):void
Add a path from the schema.
Notes:
Allows path to end with a wildcard * to import direct children example:
// to import name.firstname and name.lastnameform
Test
npm test
Mocha Coverage
npm run-script coverage
On coveralls.io
All tests are in Coffee-script, hence easy to read! Provides a great way to understand the API ;)
LICENSE
MIT