egg-async-validator
Async validate plugin for egg, sharing validator scheme between frontend and backend with Ant Design style
See async-validator for more information such as custom rule.
Install
$ npm i egg-async-validator --save
Enable plugin
// config/plugin.jsexportsvalidate = enable: true package: 'egg-async-validator';
Validate rules
validate based on scheme, which define the shape of form fields, as simple as following
const productScheme = id: type: 'string' required: true ;
Validate Request Body
// app/controller/home.jsexportsindex = async { const error = await thisthisrequestbody; if error // throw manually };
Tips
The package is so simple that it's easy to use as a npm module
; ;if errors
Questions & Suggestions
Please open an issue here.