egg-cute-validator
v1.1.5
Published
cute validator for egg
Downloads
2
Maintainers
Readme
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.