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

1.1.5 • Public • Published

egg-cute-validator

Install

$ npm i egg-cute-validator --save

Usage

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

Configuration


config.validator = {
  client: {
    locale: 'en-US',
    dirs: {
      types: '',
      messages: '',
      rules: '',
    },
  },
};

Usage:

// set messages, message format { key: value }
await this.app.validator.setMessage('zh-CN', message);

// set Locale
await this.app.validator.setLocale('zh-CN');

// validate function
await this.app.validator.validate('login.signIn', data);

// validate function, The 'default' field is set in the rule to allow the verification to fail, and the data value is changed to the default value.
await this.app.validator.parameter('login.signIn', data);

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

Example

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i egg-cute-validator

Weekly Downloads

1

Version

1.1.5

License

MIT

Unpacked Size

20.8 kB

Total Files

17

Last publish

Collaborators

  • wadecha