'use strict';

exports.__esModule = true;
exports.validNumber = undefined;

var _is = require('is');

var _is2 = _interopRequireDefault(_is);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// eslint-disable-next-line import/prefer-default-export
var validNumber = exports.validNumber = function validNumber(num, min, max) {
  if (_is2.default.number(min)) {
    // Make sure the new value isn't less than the min value.
    if (num < Number(min)) {
      return {
        showError: true,
        errorMsg: 'Please enter a valid number greater than or equal to ' + min + '.'
      };
    }
  }
  if (_is2.default.number(max)) {
    if (num > Number(max)) {
      return {
        showError: true,
        errorMsg: 'Please enter a valid number less than or equal to ' + max + '.'
      };
    }
  }
  return {
    showError: false,
    errorMsg: ''
  };
};