Skip to content

Instantly share code, notes, and snippets.

@freewil
Last active December 13, 2015 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freewil/4948693 to your computer and use it in GitHub Desktop.
Save freewil/4948693 to your computer and use it in GitHub Desktop.
var form = require('express-form'),
field = form.field;
// sync `custom`
form(
field('email')
.required()
.custom(function(email) {
if (!checkUnique(email)) {
throw new Error('Email is not unique');
}
})
);
// async `custom`
form(
field('email')
.required()
.custom(function(email, cb) {
checkUnique(email, function(err) {
if (err) {
return cb(new Error('Email is not unique'));
}
cb(null);
});
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment