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.
- package/lib/validator.d.ts +1 -1
- package/lib/validator.js +2 -2
- package/lib/validator_m.d.ts +1 -1
- package/lib/validator_m.js +2 -2
- package/package.json +1 -1
package/lib/validator.d.ts
CHANGED
@@ -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,
|
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));
|
package/lib/validator_m.d.ts
CHANGED
@@ -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_m.js
CHANGED
@@ -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,
|
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));
|