mm_validator 0.0.0-stage → 1.0.0
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/index.js +9 -0
- package/package.json +34 -4
- package/tool/abac/index.js +7 -0
- package/tool/abac/tool.json +76 -0
- package/tool/basic/index.js +7 -0
- package/tool/basic/tool.json +69 -0
- package/tool/code/index.js +7 -0
- package/tool/code/tool.json +69 -0
- package/tool/enum/index.js +7 -0
- package/tool/enum/tool.json +51 -0
- package/tool/json/index.js +7 -0
- package/tool/json/tool.json +65 -0
- package/tool/jwt/index.js +7 -0
- package/tool/jwt/tool.json +91 -0
- package/tool/length/index.js +7 -0
- package/tool/length/tool.json +53 -0
- package/tool/oauth/index.js +7 -0
- package/tool/oauth/tool.json +86 -0
- package/tool/params/index.js +7 -0
- package/tool/params/tool.json +92 -0
- package/tool/pattern/index.js +7 -0
- package/tool/pattern/tool.json +52 -0
- package/tool/range/index.js +7 -0
- package/tool/range/tool.json +79 -0
- package/tool/rbac/index.js +7 -0
- package/tool/rbac/tool.json +74 -0
- package/tool/required/index.js +7 -0
- package/tool/required/tool.json +46 -0
- package/tool/sanitize/index.js +7 -0
- package/tool/sanitize/tool.json +83 -0
- package/tool/string/index.js +7 -0
- package/tool/string/tool.json +62 -0
- package/tool/type/index.js +7 -0
- package/tool/type/tool.json +54 -0
- package/README.md +0 -3
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "oauth",
|
|
3
|
+
"handler": "validator",
|
|
4
|
+
"title": "OAuth验证器",
|
|
5
|
+
"description": "验证 OAuth 2.0 令牌,支持 Access Token 校验、刷新与吊销。适用场景:第三方登录授权校验、令牌过期处理、吊销时。工作流提示:action 选 validate/revoke 时填 access_token,选 refresh 时填 refresh_token,结果看 valid 与 errors。",
|
|
6
|
+
"type": "core",
|
|
7
|
+
"params": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"action": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "操作类型: validate/refresh/revoke",
|
|
13
|
+
"enum": [
|
|
14
|
+
"validate",
|
|
15
|
+
"refresh",
|
|
16
|
+
"revoke"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"access_token": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "访问令牌"
|
|
22
|
+
},
|
|
23
|
+
"refresh_token": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "刷新令牌"
|
|
26
|
+
},
|
|
27
|
+
"scope": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "权限范围"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"required": [
|
|
33
|
+
"action"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"returns": {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"valid": {
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"description": "验证是否通过"
|
|
42
|
+
},
|
|
43
|
+
"tip": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "提示信息,通过时为'参数校验通过',失败时包含错误数量和详情"
|
|
46
|
+
},
|
|
47
|
+
"errors": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"description": "错误信息列表"
|
|
50
|
+
},
|
|
51
|
+
"error": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"description": "错误信息,仅调用出错时返回",
|
|
54
|
+
"properties": {
|
|
55
|
+
"code": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"description": "错误码,如 VAL_OAUTH"
|
|
58
|
+
},
|
|
59
|
+
"message": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"description": "错误描述"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"options": {
|
|
68
|
+
"client_id": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"description": "OAuth客户端ID"
|
|
71
|
+
},
|
|
72
|
+
"client_secret": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"description": "OAuth客户端密钥"
|
|
75
|
+
},
|
|
76
|
+
"token_url": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "令牌端点地址"
|
|
79
|
+
},
|
|
80
|
+
"auth_url": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"description": "授权端点地址"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"group": "auth"
|
|
86
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "params",
|
|
3
|
+
"handler": "validator",
|
|
4
|
+
"title": "参数验证器",
|
|
5
|
+
"description": "统一参数验证器,按规则批量校验对象字段。适用场景:请求入参整体校验、表单提交前检查时。工作流提示:input 填待校验对象、rules 以「字段名:规则对象」声明(支持必填/类型/范围/正则/枚举等),结果看 valid 与字段级 errors。",
|
|
6
|
+
"type": "core",
|
|
7
|
+
"params": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"input": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"description": "待验证的数据对象",
|
|
13
|
+
"additionalProperties": true
|
|
14
|
+
},
|
|
15
|
+
"rules": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"description": "验证规则,key为字段名,value为规则对象",
|
|
18
|
+
"additionalProperties": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"properties": {
|
|
21
|
+
"required": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"description": "是否必填"
|
|
24
|
+
},
|
|
25
|
+
"type": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"enum": [
|
|
28
|
+
"string",
|
|
29
|
+
"number",
|
|
30
|
+
"boolean",
|
|
31
|
+
"array",
|
|
32
|
+
"object"
|
|
33
|
+
],
|
|
34
|
+
"description": "期望类型 string/number/boolean/array/object"
|
|
35
|
+
},
|
|
36
|
+
"min": {
|
|
37
|
+
"type": "number",
|
|
38
|
+
"description": "数值最小值"
|
|
39
|
+
},
|
|
40
|
+
"max": {
|
|
41
|
+
"type": "number",
|
|
42
|
+
"description": "数值最大值"
|
|
43
|
+
},
|
|
44
|
+
"min_length": {
|
|
45
|
+
"type": "number",
|
|
46
|
+
"description": "字符串/数组最小长度"
|
|
47
|
+
},
|
|
48
|
+
"max_length": {
|
|
49
|
+
"type": "number",
|
|
50
|
+
"description": "字符串/数组最大长度"
|
|
51
|
+
},
|
|
52
|
+
"pattern": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "正则表达式"
|
|
55
|
+
},
|
|
56
|
+
"enum": {
|
|
57
|
+
"type": "array",
|
|
58
|
+
"description": "允许的值列表"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": [
|
|
65
|
+
"input",
|
|
66
|
+
"rules"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"returns": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"properties": {
|
|
72
|
+
"valid": {
|
|
73
|
+
"type": "boolean",
|
|
74
|
+
"description": "是否全部通过"
|
|
75
|
+
},
|
|
76
|
+
"tip": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "提示信息,通过时为'参数校验通过',失败时包含错误数量和详情"
|
|
79
|
+
},
|
|
80
|
+
"errors": {
|
|
81
|
+
"type": "object",
|
|
82
|
+
"description": "字段级别的错误信息,key为字段名,value为错误数组"
|
|
83
|
+
},
|
|
84
|
+
"fields": {
|
|
85
|
+
"type": "object",
|
|
86
|
+
"description": "每个字段的验证结果,包含 valid 和 errors"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"options": {},
|
|
91
|
+
"group": "check"
|
|
92
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pattern",
|
|
3
|
+
"handler": "validator",
|
|
4
|
+
"title": "正则验证器",
|
|
5
|
+
"description": "校验字符串是否匹配指定正则表达式。适用场景:手机号、邮箱、身份证等格式校验,模板字符串匹配检查时。工作流提示:field 填字段名、value 填待验证字符串、pattern 填正则表达式(JS 语法),结果看 valid(boolean) 与 errors,pattern_count 为验证的规则数量。",
|
|
6
|
+
"type": "core",
|
|
7
|
+
"params": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"field": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "字段名称"
|
|
13
|
+
},
|
|
14
|
+
"value": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "待验证的字符串"
|
|
17
|
+
},
|
|
18
|
+
"pattern": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "正则表达式"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"required": [
|
|
24
|
+
"field",
|
|
25
|
+
"value",
|
|
26
|
+
"pattern"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"returns": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"properties": {
|
|
32
|
+
"valid": {
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"description": "验证是否通过"
|
|
35
|
+
},
|
|
36
|
+
"tip": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"description": "提示信息,通过时为'参数校验通过',失败时包含错误数量和详情"
|
|
39
|
+
},
|
|
40
|
+
"errors": {
|
|
41
|
+
"type": "array",
|
|
42
|
+
"description": "错误信息列表"
|
|
43
|
+
},
|
|
44
|
+
"pattern_count": {
|
|
45
|
+
"type": "number",
|
|
46
|
+
"description": "验证的规则数量"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"options": {},
|
|
51
|
+
"group": "check"
|
|
52
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "range",
|
|
3
|
+
"handler": "validator",
|
|
4
|
+
"title": "范围验证器",
|
|
5
|
+
"description": "校验数值比较关系,支持 between/not_between/>/>=/</<=/=/!=/in/not_in 十种模式。适用场景:价格区间校验、库存阈值判断、批量规则验证时。工作流提示:field/value 填字段与数值、mode 选模式、min/max 填边界,结果看 valid 与 errors。",
|
|
6
|
+
"type": "core",
|
|
7
|
+
"params": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"field": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "字段名称"
|
|
13
|
+
},
|
|
14
|
+
"value": {
|
|
15
|
+
"description": "待验证的数值"
|
|
16
|
+
},
|
|
17
|
+
"min": {
|
|
18
|
+
"description": "最小值(between / > / >= / = / != 模式)"
|
|
19
|
+
},
|
|
20
|
+
"max": {
|
|
21
|
+
"description": "最大值(between / < / <= 模式)"
|
|
22
|
+
},
|
|
23
|
+
"mode": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "比较模式: between / not_between / > / >= / < / <= / = / != / in / not_in",
|
|
26
|
+
"default": "between",
|
|
27
|
+
"enum": [
|
|
28
|
+
"between",
|
|
29
|
+
"not_between",
|
|
30
|
+
">",
|
|
31
|
+
">=",
|
|
32
|
+
"<",
|
|
33
|
+
"<=",
|
|
34
|
+
"=",
|
|
35
|
+
"!=",
|
|
36
|
+
"in",
|
|
37
|
+
"not_in"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"inclusive_min": {
|
|
41
|
+
"type": "boolean",
|
|
42
|
+
"description": "最小值是否包含边界(between 模式)",
|
|
43
|
+
"default": true
|
|
44
|
+
},
|
|
45
|
+
"inclusive_max": {
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"description": "最大值是否包含边界(between 模式)",
|
|
48
|
+
"default": true
|
|
49
|
+
},
|
|
50
|
+
"values": {
|
|
51
|
+
"type": "array",
|
|
52
|
+
"description": "候选值列表(in/not_in 模式)"
|
|
53
|
+
},
|
|
54
|
+
"rules": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"description": "批量规则列表,每项为 {field, value, min, max, mode, ...}"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"returns": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"properties": {
|
|
63
|
+
"valid": {
|
|
64
|
+
"type": "boolean",
|
|
65
|
+
"description": "验证是否通过"
|
|
66
|
+
},
|
|
67
|
+
"tip": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"description": "提示信息,通过时为'参数校验通过',失败时包含错误数量和详情"
|
|
70
|
+
},
|
|
71
|
+
"errors": {
|
|
72
|
+
"type": "array",
|
|
73
|
+
"description": "错误信息列表"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"options": {},
|
|
78
|
+
"group": "check"
|
|
79
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rbac",
|
|
3
|
+
"handler": "validator",
|
|
4
|
+
"title": "RBAC权限验证器",
|
|
5
|
+
"description": "基于角色的访问控制,校验用户角色是否拥有指定权限。适用场景:后台权限判断、菜单与接口授权、角色动态分配时。工作流提示:action 选 check 时填 user_id、role、permission 判权,add_role/remove_role 管理角色,结果看 valid 与 roles。",
|
|
6
|
+
"type": "core",
|
|
7
|
+
"params": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"action": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "操作类型: check/add_role/remove_role/list_roles",
|
|
13
|
+
"enum": [
|
|
14
|
+
"check",
|
|
15
|
+
"add_role",
|
|
16
|
+
"remove_role",
|
|
17
|
+
"list_roles"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"user_id": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "用户ID"
|
|
23
|
+
},
|
|
24
|
+
"role": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "角色名称"
|
|
27
|
+
},
|
|
28
|
+
"permission": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "权限标识"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"required": [
|
|
34
|
+
"action"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"returns": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"properties": {
|
|
40
|
+
"valid": {
|
|
41
|
+
"type": "boolean",
|
|
42
|
+
"description": "验证是否通过"
|
|
43
|
+
},
|
|
44
|
+
"tip": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "提示信息,通过时为'参数校验通过',失败时包含错误数量和详情"
|
|
47
|
+
},
|
|
48
|
+
"errors": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"description": "错误信息列表"
|
|
51
|
+
},
|
|
52
|
+
"roles": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"description": "角色信息,check 返回 {role, permission, allowed},add_role 返回 {role, permissions},list_roles 返回 {roles, mapping}"
|
|
55
|
+
},
|
|
56
|
+
"error": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"description": "错误信息,仅调用出错时返回",
|
|
59
|
+
"properties": {
|
|
60
|
+
"code": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "错误码,如 VAL_RBAC"
|
|
63
|
+
},
|
|
64
|
+
"message": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"description": "错误描述"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"options": {},
|
|
73
|
+
"group": "permission"
|
|
74
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "required",
|
|
3
|
+
"handler": "validator",
|
|
4
|
+
"title": "必填验证器",
|
|
5
|
+
"description": "校验字段值非空,拒绝 null、undefined 与空字符串。适用场景:参数校验、必填项检查,与条件分发器组合做入参守卫时。工作流提示:field 填字段名、value 填待校验值,结果看 valid(boolean) 与 errors,可配合 dispatcher.condition 分流。",
|
|
6
|
+
"type": "core",
|
|
7
|
+
"params": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"field": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "字段名称"
|
|
13
|
+
},
|
|
14
|
+
"value": {
|
|
15
|
+
"description": "待验证的值"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"required": [
|
|
19
|
+
"field",
|
|
20
|
+
"value"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"returns": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"valid": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "验证是否通过"
|
|
29
|
+
},
|
|
30
|
+
"tip": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "提示信息,通过时为'参数校验通过',失败时包含错误数量和详情"
|
|
33
|
+
},
|
|
34
|
+
"errors": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"description": "错误信息列表"
|
|
37
|
+
},
|
|
38
|
+
"required_fields": {
|
|
39
|
+
"type": "array",
|
|
40
|
+
"description": "被校验的必填字段列表"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"options": {},
|
|
45
|
+
"group": "check"
|
|
46
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sanitize",
|
|
3
|
+
"handler": "validator",
|
|
4
|
+
"title": "输入消毒器",
|
|
5
|
+
"description": "对用户输入做安全清洗,检测 SQL 注入、脚本注入与路径遍历攻击,支持对象递归处理。适用场景:外部请求入参入库前消毒、防注入与 XSS 防线时。工作流提示:input 传待清洗值,max_depth/max_string_len/max_keys 限制深度大小,结果看 valid、cleaned 与 threats。",
|
|
6
|
+
"type": "core",
|
|
7
|
+
"params": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"input": {
|
|
11
|
+
"description": "待清洗的输入值,支持字符串、对象、数组等任意类型"
|
|
12
|
+
},
|
|
13
|
+
"max_depth": {
|
|
14
|
+
"type": "integer",
|
|
15
|
+
"description": "递归清洗最大深度,默认从 options 读取"
|
|
16
|
+
},
|
|
17
|
+
"max_string_len": {
|
|
18
|
+
"type": "integer",
|
|
19
|
+
"description": "字符串最大长度,超出部分截断"
|
|
20
|
+
},
|
|
21
|
+
"max_keys": {
|
|
22
|
+
"type": "integer",
|
|
23
|
+
"description": "对象最大键数量,超出部分忽略"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"required": [
|
|
27
|
+
"input"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"returns": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"description": "返回清洗结果,正常时包含清洗后的数据和威胁检测结果,异常时包含 error",
|
|
33
|
+
"properties": {
|
|
34
|
+
"msg": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "消毒完成/消毒失败"
|
|
37
|
+
},
|
|
38
|
+
"valid": {
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"description": "是否通过安全检查"
|
|
41
|
+
},
|
|
42
|
+
"cleaned": {
|
|
43
|
+
"description": "清洗后的值"
|
|
44
|
+
},
|
|
45
|
+
"threats": {
|
|
46
|
+
"type": "array",
|
|
47
|
+
"description": "检测到的威胁类型列表 (sql_injection/script_injection/path_traversal)"
|
|
48
|
+
},
|
|
49
|
+
"error": {
|
|
50
|
+
"type": "object",
|
|
51
|
+
"description": "错误信息,仅调用出错时返回",
|
|
52
|
+
"properties": {
|
|
53
|
+
"code": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"description": "错误码 (EXEC_ 前缀)"
|
|
56
|
+
},
|
|
57
|
+
"message": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"description": "错误描述"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"options": {
|
|
66
|
+
"max_depth": {
|
|
67
|
+
"type": "integer",
|
|
68
|
+
"description": "递归清洗最大深度",
|
|
69
|
+
"default": 10
|
|
70
|
+
},
|
|
71
|
+
"max_string_len": {
|
|
72
|
+
"type": "integer",
|
|
73
|
+
"description": "字符串最大长度",
|
|
74
|
+
"default": 1048576
|
|
75
|
+
},
|
|
76
|
+
"max_keys": {
|
|
77
|
+
"type": "integer",
|
|
78
|
+
"description": "对象最大键数量",
|
|
79
|
+
"default": 1000
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"group": "security"
|
|
83
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "string",
|
|
3
|
+
"handler": "validator",
|
|
4
|
+
"title": "字符串验证器",
|
|
5
|
+
"description": "校验字符串是否满足匹配条件,支持 contains、starts_with、ends_with 三种模式。适用场景:关键词包含检查、前缀判断、后缀校验时。工作流提示:field/value 填字段与字符串、pattern 填匹配子串、mode 选模式,结果看 valid 与 errors。",
|
|
6
|
+
"type": "core",
|
|
7
|
+
"params": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"field": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "字段名称"
|
|
13
|
+
},
|
|
14
|
+
"value": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "待验证的字符串"
|
|
17
|
+
},
|
|
18
|
+
"pattern": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "匹配的子串/模式"
|
|
21
|
+
},
|
|
22
|
+
"mode": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "匹配模式: contains(包含)/ starts_with(以...开头)/ ends_with(以...结尾)",
|
|
25
|
+
"default": "contains",
|
|
26
|
+
"enum": [
|
|
27
|
+
"contains",
|
|
28
|
+
"starts_with",
|
|
29
|
+
"ends_with"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"case_sensitive": {
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"description": "是否区分大小写",
|
|
35
|
+
"default": true
|
|
36
|
+
},
|
|
37
|
+
"rules": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"description": "批量规则列表,每项为 {field, value, pattern, mode, case_sensitive}"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"returns": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"properties": {
|
|
46
|
+
"valid": {
|
|
47
|
+
"type": "boolean",
|
|
48
|
+
"description": "验证是否通过"
|
|
49
|
+
},
|
|
50
|
+
"tip": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "提示信息,通过时为'参数校验通过',失败时包含错误数量和详情"
|
|
53
|
+
},
|
|
54
|
+
"errors": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"description": "错误信息列表"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"options": {},
|
|
61
|
+
"group": "check"
|
|
62
|
+
}
|