import { isFinite, isNil } from 'lodash';
var OPTIONAL_NEGATIVE_REGEX = /^-?\d*(\.\d*)?$/;
var NON_NEGATIVE_REGEX = /^\d*(\.\d*)?$/;
export function isValueValid(value, isNegativeAllowed) {
  var regex = isNegativeAllowed ? OPTIONAL_NEGATIVE_REGEX : NON_NEGATIVE_REGEX;
  return regex.test(value);
}
export function isWithinRange(max, min, newValue) {
  var isNotBelowMin = isNil(min) || newValue >= min;
  var isNotAboveMax = isNil(max) || newValue <= max;
  return isNotBelowMin && isNotAboveMax;
}
export function canCommit(newValue, min, max) {
  var parsedValue = parseFloat(newValue);
  if (newValue === '-' || parsedValue === null) {
    return true;
  }
  return isFinite(parsedValue) && isWithinRange(max, min, parsedValue);
}