0.2.0-alpha.0 • Published 4 years ago

@jdfed/drip-form-plugin-eggjs v0.2.0-alpha.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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