isValidAmount static method
Validate amount (must be positive, reasonable limit).
Ensures the amount is positive and within reasonable limits for the specified currency. Limits are set based on typical transaction sizes for each currency.
Parameters
amount
: The amount to validate (in smallest currency unit, e.g., kobo for NGN)currency
: The currency for amount validation
Returns
true
if the amount is valid for the currency, false
otherwise.
Currency Limits
- NGN: Up to 100,000,000.00 (100 million)
- USD: Up to 1,000,000.00 (1 million)
- GHS: Up to 10,000,000.00 (10 million)
- ZAR: Up to 100,000,000.00 (100 million)
- KES: Up to 100,000,000.00 (100 million)
Implementation
static bool isValidAmount(int amount, Currency currency) {
if (amount <= 0) return false;
// Set maximum amounts based on currency (in smallest units)
const maxAmounts = {
Currency.ngn: 10000000000, // 100M NGN
Currency.usd: 100000000, // 1M USD
Currency.ghs: 1000000000, // 10M GHS
Currency.zar: 10000000000, // 100M ZAR
Currency.kes: 10000000000, // 100M KES
};
final maxAmount = maxAmounts[currency] ?? 100000000; // Default 1M
return amount <= maxAmount;
}