
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
formal-mongoose
Advanced tools

Formal + Mongoose = DRY! Simple solution to define a form with validation (and more) from a mongoose schema.
var Form = require('formal-mongoose'),
model = mongoose.model('User');
var form = new Form(model, ['name.*', 'email']);
form.field({
tos: {
type: Boolean,
default: false,
validate: function(val) {
return val === true;
}
}
});
form.set({
name: {family: 'Martinez'},
'name.first': 'José Luis Chavez',
age: 12,
tos: true
});
form.validate(function (err) {
console.log(err); // missing required email, age to low
console.log(form.get('name.first.0')); // José
console.log(form.export());
});
npm install formal-mongoose --save
Extend formal to provides fast and easy way to define a form from an existing schema. The best way to don't repeat yourself!
For the inherited prototype see the Formal API.
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 = require('formal-mongoose');
var form = new Form(mongoose.model('User'), ['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.post('/url',
// sames as (new Form({...})).middleware()
form(schema, ['username', 'password']),
function (req, res) {
console.log(req.form.data);
console.log(res.locals.form.username.value);
}
);
Add a path from the schema.
Allows path to end with a wildcard * to import direct children example:
// to import name.firstname and name.lastname
form.addPath('name.*')
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 ;)
MIT
FAQs
formal + mongoose = DRY! Define your form from your mongoose schema.
We found that formal-mongoose demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.