is-dotted-decimal.js 432 B

12345678910111213141516171819
  1. 'use strict'
  2. const partIsNotNumeric = part => /^\d+$/.test(part) === false
  3. /**
  4. * Determines if a passed in string is a dotted decimal string.
  5. *
  6. * @param {string} value
  7. *
  8. * @returns {boolean}
  9. */
  10. module.exports = function isDottedDecimal (value) {
  11. if (typeof value !== 'string') return false
  12. const parts = value.split('.')
  13. const nonNumericParts = parts.filter(partIsNotNumeric)
  14. return nonNumericParts.length === 0
  15. }