ph-utils 0.2.17 → 0.2.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,7 +39,7 @@ declare class Validator {
39
39
  * @param key 指定待验证的 key
40
40
  * @param value 待验证的数据
41
41
  */
42
- validateKey(key: string, value: any): Promise<boolean>;
42
+ validateKey(key: string, value: any, data?: any): Promise<boolean>;
43
43
  private _validateRule;
44
44
  private _parseStringRule;
45
45
  }
package/lib/validator.js CHANGED
@@ -125,10 +125,10 @@ class Validator {
125
125
  * @param key 指定待验证的 key
126
126
  * @param value 待验证的数据
127
127
  */
128
- validateKey(key, value) {
128
+ validateKey(key, value, data) {
129
129
  return new Promise((resolve, reject) => {
130
130
  let keyRules = this.rules[key];
131
- let errMsg = this._validateRule(keyRules, value, null);
131
+ let errMsg = this._validateRule(keyRules, value, data);
132
132
  if (errMsg !== '') {
133
133
  errMsg = errMsg.replace('%s', key);
134
134
  reject(new ValidateError(key, errMsg));
@@ -39,7 +39,7 @@ declare class Validator {
39
39
  * @param key 指定待验证的 key
40
40
  * @param value 待验证的数据
41
41
  */
42
- validateKey(key: string, value: any): Promise<boolean>;
42
+ validateKey(key: string, value: any, data?: any): Promise<boolean>;
43
43
  private _validateRule;
44
44
  private _parseStringRule;
45
45
  }
@@ -121,10 +121,10 @@ class Validator {
121
121
  * @param key 指定待验证的 key
122
122
  * @param value 待验证的数据
123
123
  */
124
- validateKey(key, value) {
124
+ validateKey(key, value, data) {
125
125
  return new Promise((resolve, reject) => {
126
126
  let keyRules = this.rules[key];
127
- let errMsg = this._validateRule(keyRules, value, null);
127
+ let errMsg = this._validateRule(keyRules, value, data);
128
128
  if (errMsg !== '') {
129
129
  errMsg = errMsg.replace('%s', key);
130
130
  reject(new ValidateError(key, errMsg));
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "module": "lib/index_m.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "browser": "lib/index_m.js",
8
- "version": "0.2.17",
8
+ "version": "0.2.18",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git+https//gitee.com/towardly/ph.git",