From 08e89c7e75c8404157130af8c0ebd554c7efa857 Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Fri, 8 Sep 2023 16:11:56 +0530 Subject: [PATCH 1/2] PFM-4462 --- frontend/mgramseva/lib/utils/validators/validators.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; From e512299e94ec7e9a587e5a83fd12e85922c1bb69 Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Fri, 8 Sep 2023 17:05:21 +0530 Subject: [PATCH 2/2] added regex --- .../mgramseva/lib/screeens/add_expense/expense_details.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)