Skip to main content

Function: validateNumericAmount

validateNumericAmount(amount, parameterName, allowZero?): void

Validates a decimal amount: a string or BigNumber, never a JavaScript number.

Parameters​

ParameterTypeDescription
amountNumericAmountThe amount to check.
parameterNamestringThe field name reported in the error's params.field.
allowZero?booleanAccept zero (default false).

Returns​

void

Throws​

GSwapSDKError AMOUNT_IS_JS_NUMBER, AMOUNT_NOT_FINITE, AMOUNT_NOT_POSITIVE (zero when allowZero is false) or AMOUNT_NEGATIVE.