rxtutils 1.1.4-beta.12 → 1.1.4-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/request/index.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ interface Options<Params = any, Data = any> {
|
|
|
83
83
|
* 可以配置错误码对应的错误信息或处理函数
|
|
84
84
|
* @default {} 空对象,使用默认处理函数
|
|
85
85
|
*/
|
|
86
|
-
errorCodeMap?: Record<string, string | ((code: string, data: Data, res: AxiosResponse<Data>, requestParam: RequestOptions<Params>) => ErrorHandlerReturnType<Data> | void)>;
|
|
86
|
+
errorCodeMap?: Record<string, string | ((code: string, data: Data, res: AxiosResponse<Data>, requestParam: RequestOptions<Params>) => ErrorHandlerReturnType<Data> | void | Promise<ErrorHandlerReturnType<Data> | void>)>;
|
|
87
87
|
/**
|
|
88
88
|
* 默认错误码处理函数
|
|
89
89
|
* 当错误码不在 errorCodeMap 中时调用
|
|
@@ -99,7 +99,7 @@ interface Options<Params = any, Data = any> {
|
|
|
99
99
|
* 可以配置 HTTP 状态码对应的错误信息或处理函数
|
|
100
100
|
* @default {} 空对象,使用默认处理函数
|
|
101
101
|
*/
|
|
102
|
-
httpErrorCodeMap?: Record<string, string | ((code: number, res: AxiosResponse<Data>, requestParam: RequestOptions<Params>) => Promise<ErrorHandlerReturnType<Data> | void>)>;
|
|
102
|
+
httpErrorCodeMap?: Record<string, string | ((code: number, res: AxiosResponse<Data>, requestParam: RequestOptions<Params>) => (ErrorHandlerReturnType<Data> | void | Promise<ErrorHandlerReturnType<Data> | void>))>;
|
|
103
103
|
/**
|
|
104
104
|
* 默认 HTTP 错误码处理函数
|
|
105
105
|
* 当 HTTP 状态码不在 httpErrorCodeMap 中时调用
|
|
@@ -48,9 +48,9 @@ var BaseValidator = /** @class */ (function () {
|
|
|
48
48
|
};
|
|
49
49
|
/**
|
|
50
50
|
* 验证多个或所有字段
|
|
51
|
-
* @param order
|
|
52
|
-
* @param itemAll 是否验证每个字段的所有规则,为true时会验证字段的所有规则,为false
|
|
53
|
-
* @param everyItem 是否验证所有字段,为true时会验证所有字段,为false
|
|
51
|
+
* @param order 验证字段的顺序,可以指定验证的字段名数组及其顺序,默认验证所有字段,按对象定义顺序
|
|
52
|
+
* @param itemAll 是否验证每个字段的所有规则,为true时会验证字段的所有规则,为false时遇到第一个失败的规则就停止,默认为 false
|
|
53
|
+
* @param everyItem 是否验证所有字段,为true时会验证所有字段,为false时遇到第一个失败的字段就停止,默认为 false
|
|
54
54
|
* @returns 验证错误数组,如果没有错误则返回null
|
|
55
55
|
*/
|
|
56
56
|
BaseValidator.prototype.validateAll = function (order, itemAll, everyItem) {
|
|
@@ -69,6 +69,7 @@ var BaseValidator = /** @class */ (function () {
|
|
|
69
69
|
var fn = fns_1[_a];
|
|
70
70
|
var res = fn(value);
|
|
71
71
|
if (!res.status) {
|
|
72
|
+
// 出现错误
|
|
72
73
|
if (Array.isArray(errors[res.name])) {
|
|
73
74
|
errors[res.name].push(res.message);
|
|
74
75
|
}
|
|
@@ -79,7 +80,7 @@ var BaseValidator = /** @class */ (function () {
|
|
|
79
80
|
break;
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
if (!everyItem) {
|
|
83
|
+
if (errors && !everyItem) {
|
|
83
84
|
break;
|
|
84
85
|
}
|
|
85
86
|
}
|
|
@@ -39,9 +39,9 @@ declare class BaseValidator {
|
|
|
39
39
|
validate(itemKey: string, itemAll?: boolean): string[] | null;
|
|
40
40
|
/**
|
|
41
41
|
* 验证多个或所有字段
|
|
42
|
-
* @param order
|
|
43
|
-
* @param itemAll 是否验证每个字段的所有规则,为true时会验证字段的所有规则,为false
|
|
44
|
-
* @param everyItem 是否验证所有字段,为true时会验证所有字段,为false
|
|
42
|
+
* @param order 验证字段的顺序,可以指定验证的字段名数组及其顺序,默认验证所有字段,按对象定义顺序
|
|
43
|
+
* @param itemAll 是否验证每个字段的所有规则,为true时会验证字段的所有规则,为false时遇到第一个失败的规则就停止,默认为 false
|
|
44
|
+
* @param everyItem 是否验证所有字段,为true时会验证所有字段,为false时遇到第一个失败的字段就停止,默认为 false
|
|
45
45
|
* @returns 验证错误数组,如果没有错误则返回null
|
|
46
46
|
*/
|
|
47
47
|
validateAll(order?: string[], itemAll?: boolean, everyItem?: boolean): Record<string, string[]> | null;
|
package/es/request/index.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ interface Options<Params = any, Data = any> {
|
|
|
83
83
|
* 可以配置错误码对应的错误信息或处理函数
|
|
84
84
|
* @default {} 空对象,使用默认处理函数
|
|
85
85
|
*/
|
|
86
|
-
errorCodeMap?: Record<string, string | ((code: string, data: Data, res: AxiosResponse<Data>, requestParam: RequestOptions<Params>) => ErrorHandlerReturnType<Data> | void)>;
|
|
86
|
+
errorCodeMap?: Record<string, string | ((code: string, data: Data, res: AxiosResponse<Data>, requestParam: RequestOptions<Params>) => ErrorHandlerReturnType<Data> | void | Promise<ErrorHandlerReturnType<Data> | void>)>;
|
|
87
87
|
/**
|
|
88
88
|
* 默认错误码处理函数
|
|
89
89
|
* 当错误码不在 errorCodeMap 中时调用
|
|
@@ -99,7 +99,7 @@ interface Options<Params = any, Data = any> {
|
|
|
99
99
|
* 可以配置 HTTP 状态码对应的错误信息或处理函数
|
|
100
100
|
* @default {} 空对象,使用默认处理函数
|
|
101
101
|
*/
|
|
102
|
-
httpErrorCodeMap?: Record<string, string | ((code: number, res: AxiosResponse<Data>, requestParam: RequestOptions<Params>) => Promise<ErrorHandlerReturnType<Data> | void>)>;
|
|
102
|
+
httpErrorCodeMap?: Record<string, string | ((code: number, res: AxiosResponse<Data>, requestParam: RequestOptions<Params>) => (ErrorHandlerReturnType<Data> | void | Promise<ErrorHandlerReturnType<Data> | void>))>;
|
|
103
103
|
/**
|
|
104
104
|
* 默认 HTTP 错误码处理函数
|
|
105
105
|
* 当 HTTP 状态码不在 httpErrorCodeMap 中时调用
|
|
@@ -39,9 +39,9 @@ declare class BaseValidator {
|
|
|
39
39
|
validate(itemKey: string, itemAll?: boolean): string[] | null;
|
|
40
40
|
/**
|
|
41
41
|
* 验证多个或所有字段
|
|
42
|
-
* @param order
|
|
43
|
-
* @param itemAll 是否验证每个字段的所有规则,为true时会验证字段的所有规则,为false
|
|
44
|
-
* @param everyItem 是否验证所有字段,为true时会验证所有字段,为false
|
|
42
|
+
* @param order 验证字段的顺序,可以指定验证的字段名数组及其顺序,默认验证所有字段,按对象定义顺序
|
|
43
|
+
* @param itemAll 是否验证每个字段的所有规则,为true时会验证字段的所有规则,为false时遇到第一个失败的规则就停止,默认为 false
|
|
44
|
+
* @param everyItem 是否验证所有字段,为true时会验证所有字段,为false时遇到第一个失败的字段就停止,默认为 false
|
|
45
45
|
* @returns 验证错误数组,如果没有错误则返回null
|
|
46
46
|
*/
|
|
47
47
|
validateAll(order?: string[], itemAll?: boolean, everyItem?: boolean): Record<string, string[]> | null;
|
|
@@ -46,9 +46,9 @@ var BaseValidator = /** @class */ (function () {
|
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
48
|
* 验证多个或所有字段
|
|
49
|
-
* @param order
|
|
50
|
-
* @param itemAll 是否验证每个字段的所有规则,为true时会验证字段的所有规则,为false
|
|
51
|
-
* @param everyItem 是否验证所有字段,为true时会验证所有字段,为false
|
|
49
|
+
* @param order 验证字段的顺序,可以指定验证的字段名数组及其顺序,默认验证所有字段,按对象定义顺序
|
|
50
|
+
* @param itemAll 是否验证每个字段的所有规则,为true时会验证字段的所有规则,为false时遇到第一个失败的规则就停止,默认为 false
|
|
51
|
+
* @param everyItem 是否验证所有字段,为true时会验证所有字段,为false时遇到第一个失败的字段就停止,默认为 false
|
|
52
52
|
* @returns 验证错误数组,如果没有错误则返回null
|
|
53
53
|
*/
|
|
54
54
|
BaseValidator.prototype.validateAll = function (order, itemAll, everyItem) {
|
|
@@ -67,6 +67,7 @@ var BaseValidator = /** @class */ (function () {
|
|
|
67
67
|
var fn = fns_1[_a];
|
|
68
68
|
var res = fn(value);
|
|
69
69
|
if (!res.status) {
|
|
70
|
+
// 出现错误
|
|
70
71
|
if (Array.isArray(errors[res.name])) {
|
|
71
72
|
errors[res.name].push(res.message);
|
|
72
73
|
}
|
|
@@ -77,7 +78,7 @@ var BaseValidator = /** @class */ (function () {
|
|
|
77
78
|
break;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
if (!everyItem) {
|
|
81
|
+
if (errors && !everyItem) {
|
|
81
82
|
break;
|
|
82
83
|
}
|
|
83
84
|
}
|