diff --git a/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart b/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart index 2bc19d97e..c06c0ebfe 100644 --- a/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart +++ b/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart @@ -274,7 +274,7 @@ class _ExpenseDetailsState extends State { textInputType: TextInputType.number, inputFormatter: [ FilteringTextInputFormatter.allow( - RegExp("[0-9]")) + RegExp(r"^[1-9]\d{5}$")) ], labelSuffix: '(₹)', isDisabled: (expenseDetails.allowEdit ?? true) diff --git a/frontend/mgramseva/lib/utils/validators/validators.dart b/frontend/mgramseva/lib/utils/validators/validators.dart index dffa31df9..f26ae9539 100644 --- a/frontend/mgramseva/lib/utils/validators/validators.dart +++ b/frontend/mgramseva/lib/utils/validators/validators.dart @@ -1,6 +1,7 @@ import 'package:mgramseva/utils/constants/i18_key_constants.dart'; import 'package:mgramseva/utils/localization/application_localizations.dart'; import 'package:mgramseva/utils/global_variables.dart'; +import 'dart:math' as math; class Validators { static validate(value, type) { @@ -109,7 +110,7 @@ class Validators { static String? amountValidator(String? v) { if (v!.trim().isEmpty) { return '${ApplicationLocalizations.of(navigatorKey.currentContext!).translate(i18.expense.AMOUNT_MENTIONED_IN_THE_BILL)}'; - } else if (double.parse(v) <= 0) { + } else if (double.parse(v) <= 0 || (((math.log(double.parse(v!)) / math.ln10) + 1) as int) > 6) { return '${ApplicationLocalizations.of(navigatorKey.currentContext!).translate(i18.expense.ENTER_VALID_AMOUNT)}'; } return null;