Project

validatr

0.0
No commit activity in last 3 years
No release in over 3 years
An implementation of several error checking algorithms,including Luhn and Damm.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 12.0
~> 3.6
~> 0.49
 Project Readme

Validatr

An implementation of several error checking algorithms, including Luhn and Damm, for string and number error checking.

This gem currently only supports validation of integers and strings of integers.

Installation

Add this line to your application's Gemfile:

gem "validatr"

And then execute:

$ bundle

Or install it yourself as:

$ gem install validatr

Usage

require "validatr"

Validatr::Luhn.check_digit 12345678     # => 2
Validatr::Verhoeff.check_digit 12345678 # => 4
Validatr::Damm.check_digit 12345678     # => 6

Validatr::Luhn.valid? 123456782         # => true
Validatr::Verhoeff.valid? 123456784     # => true
Validatr::Damm.valid? 123456786         # => true

123456782.valid_luhn?                   # => true
123456782.valid_verhoeff?               # => false
123456782.valid_damm?                   # => false

(123456784.0).valid_luhn?               # => false
(123456784.0).valid_verhoeff?           # => true
(123456784.0).valid_damm?               # => false

"123456786".valid_luhn?                 # => false
"123456786".valid_verhoeff?             # => false
"123456786".valid_damm?                 # => true

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/julienroger/validatr.

License

MIT

Copyright (c) 2017 Julien Roger