ManageIQ/manageiq-ui-classic

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

Summary

Maintainability
A
3 hrs
Test Coverage
ManageIQ.angular.app.directive('greaterOrZero', function() {
  return {
    require: 'ngModel',
    link: function(_scope, _elem, _attrs, ctrl) {
      ctrl.$validators.greaterOrZero = function(viewValue) {
        if (!viewValue) {
          return true;
        }
        return validInput(viewValue);
      };

      var validInput = function(s) {
        return parseFloat(s) >= 0;
      };
    },
  };
});