Skip to content

ahstro/elm-luhn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.