UNPKG

true-math

Version:

True Math - math library for numbers of arbitrary length

6 lines (4 loc) 204 B
export default function ifValidFormat(num) { const regexp = /(^-?)(\d+)(\.\d+)?$|NaN|Infinity/; if (!regexp.test(num)) throw new Error('Please enter correct number or NaN or Infinity or -Infinity'); }