GithubHelp home page GithubHelp logo

groteck / elm-iban Goto Github PK

View Code? Open in Web Editor NEW

This project forked from primait/elm-iban

0.0 1.0 0.0 21 KB

Elm library that validates IBANs

Home Page: https://package.elm-lang.org/packages/groteck/elm-iban/latest/

License: MIT License

Elm 100.00%

elm-iban's Introduction

WARNING

This is a fork to release the package in elm 0.19 the original work is from https://github.com/primait/elm-iban

I also update the license on the elm.json since the File allocated on the package was MIT.

Iban Validator

This small library started out as a module for an IBAN form validator.

Now it can parse a string to an IBAN object, that contains the Country, the CheckCode and the BBAN.

Actually CheckCode and BBAN are aliases for Strings.

Parse an IBAN

> import IBAN
> IBAN.fromString "BE68539007547034"
Ok (IBAN Belgium "68" "539007547034")
    : Result.Result IBAN.Types.Error IBAN.Types.IBAN

the fromString function performs validation as well, it checks the the IBAN length, according to the country code, and performs the sanity check pass (see https://en.wikipedia.org/wiki/International_Bank_Account_Number#Validating_the_IBAN)

Errors

the fromString function returns a Result Error IBAN, where Error can be

  1. invalid iban length according to the country
  2. the string contains invalid charactes
  3. the sanity check failed
  4. the country code is unknown

Show an IBAN

The library converts back the IBAN code in 2 string representations:

  1. textual, it is expressed in groups of four characters separated by a single space
  2. electronic without spaces
> import IBAN
> import IBAN.Types exposing (..)
> IBAN.toString Textual (IBAN Belgium "68" "539007547034")
"BE68 5390 0754 7034" : String
>
> IBAN.toString Electronic (IBAN Belgium "68" "539007547034")
"BE68539007547034" : String

Test

to run the tests

$ elm test

elm-iban's People

Contributors

francesco-bracchi avatar groteck avatar

Watchers

 avatar

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.