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
+6
View File
@@ -2012,3 +2012,9 @@ Doğrulama: 287 test geçti, üretim derlemesi başarılı.
Kur hesaplayıcısının tutar sınırı bileşen içinden çıkarılıp saf doğrulama servisine taşındı; boş, negatif, sonlu olmayan ve sınır dışı değerler için bağımsız regresyon testi eklendi.
Doğrulama: 288 test geçti, üretim derlemesi başarılı.
### 2026-09-06 · Kur tutarı tip kısıtlaması
Kur doğrulaması artık boolean, hexadecimal ve virgüllü belirsiz biçimleri kabul etmiyor; yalnızca açık ondalık sayı biçimi veya sayısal değer işleniyor.
Doğrulama: 288 test geçti, üretim derlemesi başarılı.
+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;
}
+2 -1
View File
@@ -7,5 +7,6 @@ test('exchange amount validator accepts finite non-negative amounts within limit
assert.equal(validateExchangeAmount('125,50'), false);
assert.equal(validateExchangeAmount(125.5), true);
assert.equal(validateExchangeAmount(MAX_EXCHANGE_AMOUNT), true);
for (const value of [-1, Infinity, NaN, MAX_EXCHANGE_AMOUNT + 1, null, '']) assert.equal(validateExchangeAmount(value), false);
for (const value of [-1, Infinity, NaN, MAX_EXCHANGE_AMOUNT + 1, null, '', true, false, '0x10', '1,25']) assert.equal(validateExchangeAmount(value), false);
assert.equal(validateExchangeAmount('125.50'), true);
});