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

Add public method validateBbanEntry to BbanStructure for BBAN entry validation by country #156

Merged
merged 2 commits into from
Dec 28, 2024

Conversation

PabloLec
Copy link
Contributor

@PabloLec PabloLec commented Dec 7, 2024

This PR addresses issue #155 and introduces a public API to validate specific parts of a BBAN based on the country. As described in the issue, a common use case might be validating an isolated bank code by checking its length and allowed characters, given the country.

I aimed to follow the project's coding style and implemented the public method and its logic in BbanStructure. While considering whether this should reside in IbanUtil, I concluded that a dedicated util class might not be necessary. BbanStructure already exposes public methods like forCountry and encapsulates the logic needed to validate entries for a specific country.

As part of this change, the validateBbanEntryCharacterType method was moved from IbanUtil to BbanStructure. IbanUtil now delegates BBAN entries validation to the newly created method in BbanStructure.

I kept exception handling consistent with the current codebase, continuing to use IbanFormatException as done in IbanUtil. However, there might be a discussion to have regarding whether it’s conceptually appropriate to throw an IbanFormatException when validating a single BBAN entry. I don’t have a strong opinion on this but wanted to point it out for consideration.

@hajk1 hajk1 merged commit e13e5f7 into arturmkrtchyan:master Dec 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants