export const numberFormat = (value: number) => {
  if (isNaN(value)) {
    return value;
  }

  const roundedNumber = Math.round((value + Number.EPSILON) * 100) / 100;
  const numberArray = roundedNumber.toString().split(".");
  const formatted = numberArray[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1 ");

  return numberArray[1] ? formatted + "." + numberArray[1] : formatted;
};

export const onlyNumbers = (value: string) => {
  return /^\d+$/.test(value);
};

export const hasNumber = (value: string) => {
  return /\d/.test(value);
};
