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

29 lines (25 loc) 768 B
import _ from 'lodash'; import dateMath from '@elastic/datemath'; import uiModules from 'ui/modules'; uiModules.get('kibana').directive('validateDateMath', function () { return { restrict: 'A', require: 'ngModel', scope: { 'ngModel': '=' }, link: function ($scope, elem, attr, ngModel) { ngModel.$parsers.unshift(validateDateMath); ngModel.$formatters.unshift(validateDateMath); function validateDateMath(input) { if (input == null || input === '') { ngModel.$setValidity('validDateMath', true); return null; } let moment = dateMath.parse(input); ngModel.$setValidity('validDateMath', moment != null && moment.isValid()); return input; } } }; });