ahstro/elm-luhn

Luhn Algorithm validator


License
BSD-3-Clause
Install
elm-package install ahstro/elm-luhn 1.0.0

Documentation

elm-luhn

Validate numbers using the Luhn algorithm. Can be used when writing e.g. validators for credit cards or other numbers that use the Luhn algorithm for basic validation.

Installation

elm-package install ahstro/elm-luhn

Usage

import Luhn

if Luhn.isValid "1234567812345670"
  "Yay"
else
  "Nay"


case Luhn.validate "1234567812345670" of
    Ok numberString ->
        numberString ++ " is valid" -- "1234567812345670 is valid"
    Err error ->
        error

More examples are available in the /tests folder.