restrict exchange amount input types
This commit is contained in:
@@ -2,6 +2,7 @@ const MAX_EXCHANGE_AMOUNT = 1e12;
|
||||
|
||||
export function validateExchangeAmount(value) {
|
||||
if (value === null || value === undefined || (typeof value === 'string' && !value.trim())) return false;
|
||||
if (typeof value !== 'number' && (typeof value !== 'string' || !/^\d+(?:\.\d+)?$/.test(value.trim()))) return false;
|
||||
const amount = Number(value);
|
||||
return Number.isFinite(amount) && amount >= 0 && amount <= MAX_EXCHANGE_AMOUNT;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user