Async validate plugin for egg.
See async-validator for more information such as custom rule.
$ npm i egg-async-validator --save
// config/plugin.js
exports.validate = {
enable: true,
package: 'egg-async-validator',
};
All validate rules store on app/xxxx
// app/controller/home.js
exports.index = async () => {
await this.validate({ id: 'id' }); // will throw if invalid
// or
const errors = await this.validator.validate({ id: 'id' }, this.request.body);
};
TBD
Please open an issue here.