Skip to content

Commit 3884750

Browse files
committed
reserved variables
1 parent cb50bb0 commit 3884750

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/components/CippComponents/CippCustomVariables.jsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ const CippCustomVariables = ({ id }) => {
1414
relatedQueryKeys: [`CustomVariables_${id}`],
1515
});
1616

17+
const reservedVariables = [
18+
"tenantid",
19+
"tenantname",
20+
"tenantfilter",
21+
"partnertenantid",
22+
"samappid",
23+
];
24+
25+
const validateVariableName = (value) => {
26+
if (reservedVariables.includes(value.toLowerCase())) {
27+
return "The variable name is reserved and cannot be used.";
28+
} else if (!value.includes(" ") && !/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g.test(value)) {
29+
return true;
30+
} else {
31+
return "The variable name must not contain spaces or special characters.";
32+
}
33+
};
34+
1735
const actions = [
1836
{
1937
label: "Edit",
@@ -29,18 +47,10 @@ const CippCustomVariables = ({ id }) => {
2947
{
3048
type: "textField",
3149
name: "RowKey",
32-
label: "Key",
50+
label: "Variable Name",
3351
placeholder: "Enter the key for the custom variable.",
3452
required: true,
35-
validators: {
36-
validate: (value) => {
37-
if (!value.includes(" ") && !/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g.test(value)) {
38-
return true;
39-
} else {
40-
return "The variable name must not contain spaces or special characters.";
41-
}
42-
},
43-
},
53+
validators: validateVariableName,
4454
},
4555
{
4656
type: "textField",
@@ -124,15 +134,7 @@ const CippCustomVariables = ({ id }) => {
124134
label: "Variable Name",
125135
placeholder: "Enter the name for the custom variable without %.",
126136
required: true,
127-
validators: {
128-
validate: (value) => {
129-
if (!value.includes(" ") && !/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g.test(value)) {
130-
return true;
131-
} else {
132-
return "The variable name must not contain spaces or special characters.";
133-
}
134-
},
135-
},
137+
validators: validateVariableName,
136138
},
137139
{
138140
type: "textField",

0 commit comments

Comments
 (0)