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

chore(feat): Add ABARouting number type #30

Merged
merged 4 commits into from
Apr 12, 2023
Merged

Conversation

RevinderDev
Copy link
Contributor

Hi!

I am new here so apologies in advance if I had done something out of order. This PR is proposed ABARouting number for US based banks validation. One could use it like so:

import pytest

from pydantic import BaseModel, ValidationError
from pydantic_extra_types import ABARoutingNumber


class Bank(BaseModel):
    routing_number: ABARoutingNumber
    name: str


example = [
    {"name": "US Bank Arizona", "routing_number": "122105155"},
    {"name": "US Bank California, Southern", "routing_number": "122235821"},
    {"name": "US Bank Idaho", "routing_number": "123103729"},
    {"name": "US Evil Bank Inc.", "routing_number": "123103721"},
]

assert Bank(**example[0]).routing_number == "122105155"
assert Bank(**example[1]).routing_number == "122235821"
assert Bank(**example[2]).routing_number == "123103729"
with pytest.raises(ValidationError):
    Bank(**example[3])

As a sidenote, I wanted to try and tackle opened #10 but I am not sure if @HomiGrotas is still progressing on that one or not.

@HomiGrotas
Copy link
Contributor

Hi @RevinderDev :)
I needed CountryCode PR (#14) approved to continue with the next chore.
Now when it's approved, I'm working on #10

Copy link
Collaborator

@yezz123 yezz123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

It would be good if we change the name of the file from bank.py to routing.py or something like this

@yezz123 yezz123 added the Types label Apr 11, 2023
@RevinderDev
Copy link
Contributor Author

RevinderDev commented Apr 12, 2023

I thought about it and decided against routing.py when creating that PR. The reason is that in IT, if I see routing.py / routing module, I'm thinking either API routes, or something to do with physical routers.

ABARoutingNumber is a thing only for banking (US banking specifically), therefore I named it bank.py with intention of that file having IBAN as well later on.

Alternatively, maybe there could be banking / banks module that has a file routing.py? Full path could look like this: pydantic-extra-types/types/banking/routing.py.

Or 3rd choice - routing_number.py?

Either way, I don't wanna push for my naming, so choice is yours :). LMK which one you want

@yezz123
Copy link
Collaborator

yezz123 commented Apr 12, 2023

routing_number.py

routing_number.py looks great!

@RevinderDev
Copy link
Contributor Author

routing_number.py it is then:)

@yezz123 yezz123 merged commit f98eb14 into pydantic:main Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants