You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
errors = require "errors"
|
|
|
|
amountRegex = /^[0-9]+(?:\.[0-9]+)?$/
|
|
|
|
module.exports = (amount) ->
|
|
parsedAmount = parseFloat(amount)
|
|
|
|
if amountRegex.exec(amount) == null or isNaN(parsedAmount)
|
|
throw new errors.InvalidInput("The specified amount is invalid.")
|
|
|
|
return parsedAmount
|