-
-
Notifications
You must be signed in to change notification settings - Fork 31
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 BankAccountNumber
property to Iban
class
#203
Comments
The local bank account number (not BBAN) itself cannot easily be isolated atm. as this is not defined in the specification (because this is different per country and sometimes even per bank). It isn't just the case that one can subtract the bank ID and branch ID (as far as I am aware) from the BBAN to give you the local bank account number. This API experience is maybe not intuitive/consistent, I kindof agree, but adding a The So this would work: var parser = new IbanParser(IbanRegistry.Default);
var inputIban = "GB29NWBK60161331926819";
Iban parsedIban = parser.Parse(inputIban);
string builtIban = new IbanBuilder()
.WithCountry("GB", IbanRegistry.Default)
.WithBankAccountNumber(parsedIban.Bban)
.WithBankIdentifier(parsedIban.BankIdentifier) // Technically redundant, as BBAN already has bank ID.
.WithBranchIdentifier(parsedIban.BranchIdentifier) // Technically redundant, as BBAN already has branch ID.
.Build();
Console.WriteLine(builtIban == inputIban); To further illustrate, these examples should all yield identical results: // Only with BBAN
string iban1 = new IbanBuilder()
.WithCountry("GB", registry)
.WithBankAccountNumber("NWBK60161331926819")
.Build(); // GB29NWBK60161331926819
// Branch + account nr are combined, and bank provided separately.
string iban2 = new IbanBuilder()
.WithCountry("GB", registry)
.WithBankAccountNumber("60161331926819")
.WithBankIdentifier("NWBK")
.Build(); // GB29NWBK60161331926819
// All parts separate.
string iban3 = new IbanBuilder()
.WithCountry("GB", registry)
.WithBankAccountNumber("31926819")
.WithBankIdentifier("NWBK")
.WithBranchIdentifier("601613")
.Build(); // GB29NWBK60161331926819
// Or, you can even 'overwrite' bank/branch of the bank account number:
string iban4 = new IbanBuilder()
.WithCountry("GB", registry)
.WithBankAccountNumber("ABCD000000331926819") // Full BBAN but with different bank/branch.
.WithBankIdentifier("NWBK")
.WithBranchIdentifier("601613")
.Build(); // GB29NWBK60161331926819 The order in which you call the builder methods does not matter, the builder always does this:
I understand this does not solve your problem. But in relation to your OP, we can improve the documentation of course or perhaps you have other suggestion/idea? |
Is your feature request related to a problem? Please describe.
IbanBuilder
has aWithBankAccountNumber(string)
method, yet there is no correspondingBankAccountNumber
property on theIban
object. This means it's possible to build up an IBAN from its various parts, but impossible to get those same parts back out without performing manual parsing, which is a confusing API experience.Describe the solution you'd like
Add property
string BankAccountNumber
onIban
.Describe alternatives you've considered
Parsing.
Additional context
N/A
The text was updated successfully, but these errors were encountered: