node.js - How to create a custom asynchronous validator in express-validator? -
i want create custom validator to check duplicate email in database. how can ?
according the docs, add in object defines each validator want use.
app.use(expressvalidator({ customvalidators: { isarray: function(value) { return array.isarray(value); }, gte: function(param, num) { return param >= num; } } }));
it looks docs not cover asynchronous stuff (e.g. checking db), there pull request several years ago added ability return promise custom validator.
Comments
Post a Comment