This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Luhn Algorithm validator
version 1.0.0
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.0
Committed At 2018-01-02 11:32:00 UTC
elm-lang/core 5.0.0 <= v < 6.0.0 5.1.1

Modules

README

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