CAKE-185 | changed isValidAmount() in the exchange_view_model.dart

OleksandrSobol committed Nov 27, 2020 at 08:50 UTC 623299b8f6ba9920d15d62eb46a766ecffde95a5
1 file changed +2 -9
lib/view_model/exchange/exchange_view_model.dart
+2 -9
@@ -313,15 +313,8 @@ abstract class ExchangeViewModelBase with Store {
313 final amount = isReceiveAmountEntered
314 ? receiveAmount
315 : depositAmount;
316 -
317 - final amountParts = amount.replaceAll(',', '.')
318 - .split('.');
319 -
320 - final numberOfFractionDigits =
321 - amountParts.length > 1
322 - ? amountParts[1].length : 0;
323 -
324 - isValid = !(numberOfFractionDigits > 8);
316 + isValid = RegExp('^([0-9]+([.\,][0-9]{0,8})?|[.\,][0-9]{1,8})\$')
317 + .hasMatch(amount);
318 }
319
320 return isValid;