Automatically migrated from Gitolite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

11 lines
281 B

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