mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Templating: added validation for allowed characters in variable names, Closes #1106
This commit is contained in:
@@ -45,6 +45,11 @@ function (angular, _) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$scope.current.name.match(/^\w+$/)) {
|
||||||
|
$scope.appEvent('alert-warning', ['Validation', 'Only word and digit characters are allowed in variable names']);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var sameName = _.findWhere($scope.variables, { name: $scope.current.name });
|
var sameName = _.findWhere($scope.variables, { name: $scope.current.name });
|
||||||
if (sameName && sameName !== $scope.current) {
|
if (sameName && sameName !== $scope.current) {
|
||||||
$scope.appEvent('alert-warning', ['Validation', 'Variable with the same name already exists']);
|
$scope.appEvent('alert-warning', ['Validation', 'Variable with the same name already exists']);
|
||||||
|
|||||||
Reference in New Issue
Block a user