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

38 lines (33 loc) 940 B
import _ from 'lodash'; import Ipv4Address from 'ui/utils/ipv4_address'; import uiModules from 'ui/modules'; uiModules .get('kibana') .directive('validateIp', function () { return { restrict: 'A', require: 'ngModel', scope: { 'ngModel': '=', }, link: function ($scope, elem, attr, ngModel) { function validateIp(ipAddress) { if (ipAddress == null || ipAddress === '') { ngModel.$setValidity('ipInput', true); return null; } try { ipAddress = new Ipv4Address(ipAddress); ngModel.$setValidity('ipInput', true); return ipAddress.toString(); } catch (e) { ngModel.$setValidity('ipInput', false); } } // From User ngModel.$parsers.unshift(validateIp); // To user ngModel.$formatters.unshift(validateIp); } }; });