Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #75

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions transaction_processing/transaction_routing.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
class TransactionRouter:
def __init__(self):
self.routing_rules = {
'domestic': {
'regex': r'^\d{10}$',
'message': 'Invalid account number format. Please enter a 10-digit account number.'
"domestic": {
"regex": r"^\d{10}$",
"message": "Invalid account number format. Please enter a 10-digit account number.",
},
"international": {
"regex": r"^\d{12}$",
"message": "Invalid account number format. Please enter a 12-digit account number.",
},
'international': {
'regex': r'^\d{12}$',
'message': 'Invalid account number format. Please enter a 12-digit account number.'
}
}

def route_transaction(self, transaction):
for rule in self.routing_rules:
if re.match(self.routing_rules[rule]['regex'], transaction['account_number']):
if re.match(
self.routing_rules[rule]["regex"], transaction["account_number"]
):
return rule
raise ValueError('Invalid account number format.')
raise ValueError("Invalid account number format.")
Loading