export const validateTextfieldDigits = ({ value, min, max }) => {
  const newValue = parseInt(value.replace(/\D/g, ''), 10);

  if (Number.isNaN(newValue)) {
    return '';
  }

  if (newValue >= min && newValue <= max) {
    return newValue;
  }

  return null;
};

export default validateTextfieldDigits;

export const integerFieldBlockInvalidChar = (e) => ['e', 'E', '+', '-', '.'].includes(e.key) && e.preventDefault();
