Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

egg-ivalidate

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-ivalidate

the async validator plugin for egg, compatible egg-validate method

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

egg-async-validate

Validate plugin for egg, compatible egg-validate method.

see async-validate for more information such as custom rule.

Install

$ npm i egg-ivalidate --save

Usage

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

Configuration

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

see async-validator#messages for more detail.

Example

// {app_root}/app/controller/home.js
exports.index = async ctx => {

  // will throw if invalid.
  await ctx.validate({
    data: { type: 'object', required: true },
  }, {
    data: '1',
  });

  // if you want to get errors info,
  // use try { ... } catch (err) { ... } to get
  // example
  try {
    await ctx.validate({ data: { type: 'object', required: true } }); // validate target, default to `this.request.body`
  } catch (err) {
    const errors = err.errors;
  }

};

rules see async-validator#rules for more detail.

!!important: method,date,hex in type does not apply to server - side form validation

Keywords

FAQs

Package last updated on 11 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc