restrict exchange amount input types
This commit is contained in:
@@ -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.
|
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ı.
|
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ı.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const MAX_EXCHANGE_AMOUNT = 1e12;
|
|||||||
|
|
||||||
export function validateExchangeAmount(value) {
|
export function validateExchangeAmount(value) {
|
||||||
if (value === null || value === undefined || (typeof value === 'string' && !value.trim())) return false;
|
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);
|
const amount = Number(value);
|
||||||
return Number.isFinite(amount) && amount >= 0 && amount <= MAX_EXCHANGE_AMOUNT;
|
return Number.isFinite(amount) && amount >= 0 && amount <= MAX_EXCHANGE_AMOUNT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,50'), false);
|
||||||
assert.equal(validateExchangeAmount(125.5), true);
|
assert.equal(validateExchangeAmount(125.5), true);
|
||||||
assert.equal(validateExchangeAmount(MAX_EXCHANGE_AMOUNT), 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);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user