From 5e6d39e0812b60e65ceaa38144822b2ba85dd6a8 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 12:37:12 +0000 Subject: [PATCH] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 978d3bc according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- .../transaction_validation.py | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/transaction_processing/transaction_validation.py b/transaction_processing/transaction_validation.py index f119832ff..23da6ba7e 100644 --- a/transaction_processing/transaction_validation.py +++ b/transaction_processing/transaction_validation.py @@ -1,17 +1,18 @@ import re + class TransactionValidation: def __init__(self): self.validation_rules = { - 'account_number': { - 'regex': r'^\d{10}$', - 'message': 'Invalid account number format. Please enter a 10-digit account number.' + "account_number": { + "regex": r"^\d{10}$", + "message": "Invalid account number format. Please enter a 10-digit account number.", + }, + "amount": { + "min": 0, + "max": 1000000, + "message": "Transaction amount must be between 0 and 1,000,000.", }, - 'amount': { - 'min': 0, - 'max': 1000000, - 'message': 'Transaction amount must be between 0 and 1,000,000.' - } } def validate_transaction(self, transaction): @@ -19,13 +20,17 @@ def validate_transaction(self, transaction): for field, rules in self.validation_rules.items(): if field in transaction: for rule in rules: - if rule == 'regex': + if rule == "regex": if not re.match(rules[rule], transaction[field]): - errors.append(rules['message']) - elif rule == 'min': + errors.append(rules["message"]) + elif rule == "min": if float(transaction[field]) < rules[rule]: - errors.append(f'Transaction amount must be at least {rules[rule]}') - elif rule == 'max': + errors.append( + f"Transaction amount must be at least {rules[rule]}" + ) + elif rule == "max": if float(transaction[field]) > rules[rule]: - errors.append(f'Transaction amount must not exceed {rules[rule]}') + errors.append( + f"Transaction amount must not exceed {rules[rule]}" + ) return errors