ManageIQ/manageiq-ui-classic

View on GitHub
app/javascript/oldjs/directives/reconfigure/validateTotal.js

Summary

Maintainability
A
0 mins
Test Coverage
ManageIQ.angular.app.directive('validateTotal', function() {
  return {
    require: 'ngModel',
    link: function(_scope, _elm, attrs, ctrl) {
      var maxvalue = attrs.miqmax;
      ctrl.$validators.integer = function(modelValue, viewValue) {
        if (ctrl.$isEmpty(modelValue)) {
          return false;
        }

        var x = parseInt(viewValue, 10);
        if (x <= parseInt(maxvalue, 10)) {
          return true;
        }

        return false;
      };
    },
  };
});