ManageIQ/manageiq-ui-classic

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

Summary

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

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