@@ -14,6 +14,24 @@ const CippCustomVariables = ({ id }) => {
14
14
relatedQueryKeys : [ `CustomVariables_${ id } ` ] ,
15
15
} ) ;
16
16
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
+
17
35
const actions = [
18
36
{
19
37
label : "Edit" ,
@@ -29,18 +47,10 @@ const CippCustomVariables = ({ id }) => {
29
47
{
30
48
type : "textField" ,
31
49
name : "RowKey" ,
32
- label : "Key " ,
50
+ label : "Variable Name " ,
33
51
placeholder : "Enter the key for the custom variable." ,
34
52
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 ,
44
54
} ,
45
55
{
46
56
type : "textField" ,
@@ -124,15 +134,7 @@ const CippCustomVariables = ({ id }) => {
124
134
label : "Variable Name" ,
125
135
placeholder : "Enter the name for the custom variable without %." ,
126
136
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 ,
136
138
} ,
137
139
{
138
140
type : "textField" ,
0 commit comments