Skip to content

Commit

Permalink
feat(frontend): 权限规则db校验规则 #8407
Browse files Browse the repository at this point in the history
  • Loading branch information
JustaCattt authored and jinquantianxia committed Dec 12, 2024
1 parent 5451439 commit acd943e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,21 @@
return _.every(dbs, (item) => !!item.trim());
},
},
{
required: true,
trigger: 'blur',
message: t('访问 DB 名不允许为 admin'),
validator: (value: string) => /^(?!admin$).*/.test(value),
},
{
required: true,
trigger: 'blur',
message: t('请输入访问DB名_以字母开头_支持字母_数字_下划线_多个使用英文逗号_分号或换行分隔'),
validator: (value: string) => {
const dbs = value.split(/[\n;,]/);
return _.every(dbs, (item) => (!item ? true : /^[A-Za-z][A-Za-z0-9_]*$/.test(item)));
},
},
{
required: true,
trigger: 'blur',
Expand All @@ -237,21 +252,6 @@
});
},
},
{
required: true,
trigger: 'blur',
message: t('访问 DB 名不允许为 admin'),
validator: (value: string) => /^(?!admin$).*/.test(value),
},
{
required: true,
trigger: 'blur',
message: t('请输入访问DB名_以字母开头_支持字母_数字_下划线_多个使用英文逗号_分号或换行分隔'),
validator: (value: string) => {
const dbs = value.split(/[\n;,]/);
return _.every(dbs, (item) => (!item ? true : /^(?:[a-zA-Z].*$)/.test(item)));
},
},
],
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
return _.every(dbs, (item) =>
!item
? true
: /^%?[a-zA-Z0-9]([a-zA-Z0-9_-])*[a-zA-Z0-9]$/.test(item) && /^(?!stage_truncate).*/.test(item),
: /^[a-zA-Z0-9%]([a-zA-Z0-9_%-])*[a-zA-Z0-9%]$/.test(item) && /^(?!stage_truncate).*/.test(item),
);
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@
return _.every(dbs, (item) => !!item.trim());
},
},
{
required: true,
trigger: 'blur',
message: t('请输入访问DB名_以字母开头_支持 % 通配符 或 % 单独使用代表ALL_多个使用英文逗号_分号或换行分隔'),
validator: (value: string) => {
const dbs = value.split(/[\n;,]/);
return _.every(dbs, (item) => (!item ? true : /^(?:[a-zA-Z].*|%$)/.test(item)));
},
},
{
required: true,
trigger: 'blur',
Expand All @@ -213,15 +222,6 @@
});
},
},
{
required: true,
trigger: 'blur',
message: t('请输入访问DB名_以字母开头_支持 % 通配符 或 % 单独使用代表ALL_多个使用英文逗号_分号或换行分隔'),
validator: (value: string) => {
const dbs = value.split(/[\n;,]/);
return _.every(dbs, (item) => (!item ? true : /^(?:[a-zA-Z].*|%$)/.test(item)));
},
},
],
};
Expand Down

0 comments on commit acd943e

Please sign in to comment.