Skip to content

Commit

Permalink
Merge pull request #75 from KOSASIH/deepsource-transform-c0e8ede4
Browse files Browse the repository at this point in the history
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
  • Loading branch information
KOSASIH authored May 10, 2024
2 parents da13114 + 8660b46 commit ee657d1
Showing 1 changed file with 11 additions and 9 deletions.
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.")

0 comments on commit ee657d1

Please sign in to comment.