egg-validate2
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

egg-validate2

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-validate2 --save

Usage

// {app_root}/config/plugin.js
exports.validate = {
  enable: true,
  package: 'egg-validate2',
};

Configuration

// {app_root}/config/config.default.js
exports.validate = {
};

see config/config.default.js for more detail.

Example

'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {
    async index() {
        const { ctx } = this;

        await ctx.validator().validate({title: [{required: true, message: 'title is required!'}]},ctx.request.query);

        ctx.body = 'hi, egg';
    }
}

module.exports = HomeController;

See async-validator for more information such as custom rule.

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i egg-validate2

Weekly Downloads

1

Version

1.1.2

License

MIT

Unpacked Size

14.3 kB

Total Files

11

Last publish

Collaborators

  • ron_dong