Git Product home page Git Product logo

bankster's People

Contributors

jarroput avatar maennchen avatar railsmechanic avatar szymon-jez avatar warmwaffles avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bankster's Issues

Does not support new IBAN countries (e.g. PK - Pakistan)

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).

"&&" in the IBAN checksum causes exception in validation

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.

Function for returning the country code should validate

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:

def country_code(iban) do
iban
|> format_default()
|> String.slice(0..1)
end

Change from returning a simple string to
{:ok, "DE"} or {:error, :invalid_country}

This is a breaking change!

[Be Aware] Wrong IBAN Validations

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}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.