eggjs/egg-validate

Name: egg-validate

Owner: egg

Description: validate plugin for egg

Created: 2016-07-17 06:23:58.0

Updated: 2018-05-21 09:35:52.0

Pushed: 2018-05-17 00:42:22.0

Homepage: null

Size: 14

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

egg-validate

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

Validate plugin for egg.

see parameter for more information such as custom rule.

Install
m i egg-validate --save
Usage
app_root}/config/plugin.js
rts.validate = {
ckage: 'egg-validate',

Validate Request Body
app_root}/app/controller/home.js
rts.index = function* () {
is.validate({ id: 'id' }); // will throw if invalid
 or
nst errors = this.validator.validate({ id: 'id' }, this.request.body);

Extend Rules
validator.addRule('jsonString', (rule, value) => {
y {
JSON.parse(value);
catch (err) {
return 'must be json string';


Questions & Suggestions

Please open an issue here.

License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.