ManageIQ/manageiq-ui-classic

View on GitHub
app/javascript/oldjs/directives/detect_spaces.js

Summary

Maintainability
A
0 mins
Test Coverage
ManageIQ.angular.app.directive('detectSpaces', function() {
  return {
    require: 'ngModel',
    link: function(_scope, _elem, _attrs, ctrl) {
      ctrl.$validators.detectedSpaces = function(modelValue, viewValue) {
        if (viewValue === undefined || (viewValue !== undefined && !detectedSpaces(viewValue))) {
          return true;
        }
        return false;
      };

      var detectedSpaces = function(s) {
        return /\s/g.test(s);
      };
    },
  };
});