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

fix(finance.bic): remove hardcoded elements and simplify function #1171

Merged
merged 7 commits into from Aug 1, 2022

Conversation

hankucz
Copy link
Contributor

@hankucz hankucz commented Jul 20, 2022

Fixes #1159

@hankucz hankucz requested a review from a team as a code owner July 20, 2022 10:32
@codecov
Copy link

codecov bot commented Jul 20, 2022

Codecov Report

Merging #1171 (279d378) into main (aafab45) will increase coverage by 0.00%.
The diff coverage is 92.85%.

@@           Coverage Diff           @@
##             main    #1171   +/-   ##
=======================================
  Coverage   99.62%   99.62%           
=======================================
  Files        2153     2153           
  Lines      236547   236543    -4     
  Branches      979      979           
=======================================
- Hits       235656   235654    -2     
+ Misses        870      868    -2     
  Partials       21       21           
Impacted Files Coverage Δ
src/modules/finance/index.ts 99.76% <92.85%> (+0.45%) ⬆️

@xDivisionByZerox xDivisionByZerox requested a review from a team July 20, 2022 10:56
@xDivisionByZerox xDivisionByZerox added the c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs label Jul 20, 2022
@xDivisionByZerox xDivisionByZerox added this to the v7 - Current Major milestone Jul 20, 2022
@xDivisionByZerox xDivisionByZerox added p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug labels Jul 20, 2022
@ST-DDT
Copy link
Member

ST-DDT commented Jul 20, 2022

One regex seems to be failing. Please check the regex for issues.
Is there a validator.js function for that or we could propose it there?

@ST-DDT
Copy link
Member

ST-DDT commented Jul 20, 2022

Edit I found this "official" regex: https://stackoverflow.com/a/52043851/4573065
Maybe use somewhere official is source for it?

@hankucz
Copy link
Contributor Author

hankucz commented Jul 20, 2022

Edit I found this "official" regex: https://stackoverflow.com/a/52043851/4573065
Maybe use somewhere official is source for it?

According to https://wise.com/gb/swift-codes/bic-swift-code-checker the location code is 0-9 A-Z. I checked the failed bic YAQHKI1MIMQ and got results:

  • Your 4-digit bank code YAQH was not found, but may be correct.
  • Your 2-digit country code KI is for Kiribati
  • Your 2-digit location code 1M was not found but may be correct.
  • Your 3-digit branch code IMQ was not found but may be correct.

Supported by wikipedia https://en.wikipedia.org/wiki/ISO_9362
But then the german version adds some more rules: https://de.wikipedia.org/wiki/ISO_9362

I found the official (demo) standard https://cdn.standards.iteh.ai/samples/84108/21078408ed25469391d0cf6c5d1b6ca9/ISO-9362-2022.pdf and it also does not say anything about those exclusions mentioned on German wiki.

@ST-DDT
Copy link
Member

ST-DDT commented Jul 21, 2022

Then use a simple regex. I would even remove the countryCodes from the regex and check them separately (e.g. using substring).

@import-brain import-brain added the needs rebase There is a merge conflict label Jul 22, 2022
# Conflicts:
#	test/__snapshots__/finance.spec.ts.snap
# Conflicts:
#	test/__snapshots__/finance.spec.ts.snap
@hankucz
Copy link
Contributor Author

hankucz commented Jul 26, 2022

Rebased and issues fixed. Is it ready to merge?

@xDivisionByZerox xDivisionByZerox removed the needs rebase There is a merge conflict label Jul 26, 2022
pkuczynski
pkuczynski previously approved these changes Jul 26, 2022
@xDivisionByZerox xDivisionByZerox added the m: finance Something is referring to the finance module label Jul 28, 2022
@hankucz
Copy link
Contributor Author

hankucz commented Aug 1, 2022

The suggested change by @ST-DDT was implemented into the test. Is this ready for merge?

@ST-DDT ST-DDT enabled auto-merge (squash) August 1, 2022 17:20
@ST-DDT ST-DDT merged commit 5a397e0 into faker-js:main Aug 1, 2022
@hankucz hankucz deleted the fix-bic branch August 3, 2022 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs m: finance Something is referring to the finance module p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

BIC generation is not realistic
6 participants