We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7c063fc commit c4326d2Copy full SHA for c4326d2
1 file changed
README.md
@@ -56,11 +56,16 @@ exports.validate = {
56
57
```js
58
// app/controller/home.js
59
-exports.index = function* () {
60
- this.validate({ id: 'id' }); // will throw if invalid
61
- // or
62
- const errors = this.app.validator.validate({ id: 'id' }, this.request.body);
63
-};
+const Controller = require('egg').Controller;
+class HomeController extends Controller {
+ async index() {
+ const { ctx, app } = this;
+ ctx.validate({ id: 'id' }); // will throw if invalid
64
+ // or
65
+ const errors = app.validator.validate({ id: 'id' }, ctx.request.body);
66
+ }
67
+}
68
+module.exports = HomeController;
69
```
70
71
### Extend Rules
0 commit comments