restrict exchange amount input types

This commit is contained in:
2026-09-06 18:15:21 +03:00
parent a76a35c14d
commit c1e542f634
3 changed files with 9 additions and 1 deletions
+1
View File
@@ -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;
}