# gluhn

A Luhn algorithm library for Gleam.

[![Package Version](https://img.shields.io/hexpm/v/gluhn)](https://hex.pm/packages/gluhn)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/gluhn/)

```sh
gleam add gluhn@1
```
```gleam
import gluhn

pub fn main() -> Nil {
  // Generate a Luhn-valid 10 digit number
  let assert Ok(valid_number) = gluhn.generate(n: 10)

  // Calculate the checksum digit of a number
  let regular_number = 123_456_789
  let assert 7 = gluhn.checksum(regular_number)

  // Check if a number is Luhn-valid
  let assert True = gluhn.validate(valid_number)
}
```

Further documentation can be found at <https://hexdocs.pm/gluhn>.

## Development

```sh
gleam test  # Run the tests

gleam format # Format code
```

## License

This project is licensed under the **Apache License 2.0**. See the [LICENSE](./LICENSE) file for details.
