@jdfed/drip-form-plugin-eggjs

0.2.0-alpha.0 • Public • Published

drip-form-plugin-eggjs

drip-form plugin for eggjs.

Install

$ npm i @jdfed/drip-form-plugin-eggjs --save

Usage

// {app_root}/config/plugin.js
exports.dripValidator = {
  enable: true,
  package: '@jdfed/drip-form-plugin-eggjs',
};

Example

// app/controller/home.js
const Controller = require('egg').Controller;
class HomeController extends Controller {
  async index() {
    const rules = {
      type: 'object',
      properties: {
        name: {
          type: 'string',
        },
        age: {
          type: 'integer',
        },
      },
      required: [
        'name',
        'age',
      ],
    };
    this.ctx.validateBySchema(rules);
    this.ctx.body = 'ok!';
  }
}
module.exports = HomeController;

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i @jdfed/drip-form-plugin-eggjs

Weekly Downloads

0

Version

0.2.0-alpha.0

License

MIT

Unpacked Size

5.34 kB

Total Files

7

Last publish

Collaborators

  • qishaoxuan
  • helloqian12138
  • tinymins
  • crazywood007
  • mengshang918