Skip to content

Ron-Dong/egg-validate2

Repository files navigation

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.validate2 = {
  enable: true,
  package: 'egg-validate2',
};

Configuration

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

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published