railsmechanic / bankster Goto Github PK
View Code? Open in Web Editor NEWAn IBAN account numbers and BIC validation tool for Elixir.
Home Page: https://hex.pm/packages/bankster
License: MIT License
An IBAN account numbers and BIC validation tool for Elixir.
Home Page: https://hex.pm/packages/bankster
License: MIT License
Example valid IBAN number taken from IBAN.com: PK36SCBL0000001123456702
is said by Bankster to be invalid:
iex(13)> Bankster.Iban.valid?("PK36SCBL0000001123456702")
false
iex(14)> Bankster.Iban.validate("PK36SCBL0000001123456702")
{:error, :invalid_country}
Stumbled upon when using Bankster together with Faker (Faker.Code.iban
).
iex(3)> Bankster.Iban.validate("PK36SCBL0000001123456702")
{:ok, "PK36SCBL0000001123456702"}
iex(4)> Bankster.Iban.validate("PK33SCBL0000001123456702")
{:error, :invalid_checksum}
iex(5)> Bankster.Iban.validate("PK&&SCBL0000001123456702")
** (ArgumentError) argument error
:erlang.binary_to_integer("2812112100000011234567022520&&")
(bankster) lib/bankster/iban.ex:301: Bankster.Iban.iban_violates_checksum?/1
(bankster) lib/bankster/iban.ex:246: Bankster.Iban.validate/1
The IBAN format validation should catch this.
The function which returns the country code for a given IBAN should check whether the given country code of the IBAN is within the list of supported countries:
Lines 187 to 191 in 1572aaf
Change from returning a simple string to
{:ok, "DE"}
or {:error, :invalid_country}
This is a breaking change!
Use the test IBANs from https://www.iban.com/testibans, I noticed that the library is not validating IBAN correctly.
invalid_ibans = ~w(
GB94BARC20201530093459
GB96BARC202015300934591
GB02BARC20201530093451
GB68CITI18500483515538
GB24BARC20201630093459
GB12BARC20201530093A59
GB78BARCO0201530093459
GB2LABBY09012857201707
GB01BARC20714583608387
GB00HLFX11016111455365
US64SVBKUS6S3300958879
)
Enum.each(invalid_ibans, fn iban ->
iban
|> Bankster.iban_validate()
|> IO.inspect()
end)
{:error, :invalid_checksum}
{:error, :invalid_length}
{:ok, "GB02BARC20201530093451"}
{:ok, "GB68CITI18500483515538"}
{:ok, "GB24BARC20201630093459"}
{:error, :invalid_format}
{:error, :invalid_format}
{:ok, "GB2LABBY09012857201707"}
{:ok, "GB01BARC20714583608387"}
{:ok, "GB00HLFX11016111455365"}
{:error, :invalid_country}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.