https://github.com/ahstro/elm-luhn
Validate numbers using the Luhn algorithm
https://github.com/ahstro/elm-luhn
Last synced: about 1 year ago
JSON representation
Validate numbers using the Luhn algorithm
- Host: GitHub
- URL: https://github.com/ahstro/elm-luhn
- Owner: ahstro
- License: bsd-3-clause
- Created: 2018-01-02T11:33:27.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-03-18T17:24:59.000Z (over 6 years ago)
- Last Synced: 2025-02-05T13:20:00.396Z (over 1 year ago)
- Language: Elm
- Homepage: http://package.elm-lang.org/packages/ahstro/elm-luhn/latest
- Size: 8.79 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-luhn
Validate numbers using the [Luhn algorithm](https://en.wikipedia.org/wiki/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
```sh
elm-package install ahstro/elm-luhn
```
## Usage
```elm
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](https://github.com/ahstro/elm-luhn/tree/master/tests) folder.