ahstro / elm-luhn / Luhn

This library allows you to validate data using the Luhn Algorithm. The algorithm is often used to guard against simple mistakes when a user enters something like a credit card or social security number.

Validation

validate : String -> Result String String

Accepts a string and returns a Result String String indicating whether the string was a valid number according to the Luhn Algorithm.

validate "49927398716" == Ok "49927398716"

isValid : String -> Basics.Bool

Same as validate but returns a Bool instead, for easy use in if-expressions.

isValid "49927398716" == True