faker icon indicating copy to clipboard operation
faker copied to clipboard

Branch code option for SWIFT/BIC codes

Open ejcheng opened this issue 3 years ago • 6 comments

From bank.codes: "SWIFT codes are laid out in a standard format. You'll find 8 letters or digits for a standard SWIFT code, or 11 if you also have the branch code added. The last 3 digits which show the specific branch an account is held at are not always necessary."

Currently, finance.bic() uses a ternary operator https://github.com/faker-js/faker/blob/df9c650432de2d119b4f17d61a0c554b744debd0/src/modules/finance/index.ts#L412-L414 to randomly decide whether to generate an 8 char or 11 char SWIFT code.

I propose that we add a boolean branchCode parameter to finance.bic() to give users the ability to pick whether they want a standard SWIFT code or a code with the branch code at the end.

ejcheng avatar Jul 17 '22 22:07 ejcheng

It should still be possible to call the function and get 8 or 11 as result so your test suit can handle both kind of data So we might need a string union literal. Also consider using an option object, even if there is currently only one option, but it's more easy extendable.

Shinigami92 avatar Jul 18 '22 00:07 Shinigami92

FFR: https://github.com/faker-js/faker/blob/df9c650432de2d119b4f17d61a0c554b744debd0/src/modules/finance/index.ts#L412-L414

ST-DDT avatar Jul 18 '22 02:07 ST-DDT

It should still be possible to call the function and get 8 or 11 as result so your test suit can handle both kind of data So we might need a string union literal. Also consider using an option object, even if there is currently only one option, but it's more easy extendable.

Yeah, most of the functions with parameters use options objects, so we should keep it consistent and have one here as well.

ejcheng avatar Jul 18 '22 02:07 ejcheng

I fixed the bug in #1171, and if you accept it I can extend it with these additional parameters to control branch code generation...

hankucz avatar Jul 20 '22 10:07 hankucz

I fixed the bug in #1171, and if you accept it I can extend it with these additional parameters to control branch code generation...

Hmm, I would say submit #1171 first, then make a new PR with the options object and new parameter added to the function. Thank you for your PR!

ejcheng avatar Jul 20 '22 15:07 ejcheng

I fixed the bug in #1171, and if you accept it I can extend it with these additional parameters to control branch code generation...

Hi Hanna, are you on this issue? I could take it, if you wish. Thank you for your help with the implementation fix!

ejcheng avatar Sep 04 '22 16:09 ejcheng