Add public method validateBbanEntry to BbanStructure for BBAN entry validation by country #156
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 inIbanUtil
, I concluded that a dedicated util class might not be necessary.BbanStructure
already exposes public methods likeforCountry
and encapsulates the logic needed to validate entries for a specific country.As part of this change, the
validateBbanEntryCharacterType
method was moved fromIbanUtil
toBbanStructure
.IbanUtil
now delegates BBAN entries validation to the newly created method inBbanStructure
.I kept exception handling consistent with the current codebase, continuing to use
IbanFormatException
as done inIbanUtil
. However, there might be a discussion to have regarding whether it’s conceptually appropriate to throw anIbanFormatException
when validating a single BBAN entry. I don’t have a strong opinion on this but wanted to point it out for consideration.