UNPKG

kibana-123

Version:

Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic

33 lines (28 loc) 1.03 kB
import _ from 'lodash'; import uiModules from 'ui/modules'; // See https://github.com/elastic/elasticsearch/issues/6736 uiModules .get('kibana') .directive('validateIndexName', function () { return { restrict: 'A', require: 'ngModel', link: function ($scope, elem, attr, ngModel) { const illegalCharacters = ['\\', '/', '?', '"', '<', '>', '|', ' ', ',']; const allowWildcard = !_.isUndefined(attr.allowWildcard) && attr.allowWildcard !== 'false'; if (!allowWildcard) { illegalCharacters.push('*'); } let isValid = function (input) { if (input == null || input === '' || input === '.' || input === '..') return false; let match = _.find(illegalCharacters, function (character) { return input.indexOf(character) >= 0; }); return !match; }; ngModel.$validators.indexNameInput = function (modelValue, viewValue) { return isValid(viewValue); }; } }; });