Luhn check
With the luhn-check gem you can validate a number with the Luhn algorithm. This is commonly used to check validity of creditcard numbers and others.
Installation
In your Gemfile:
gem 'luhn-check', '~> 0.0.5', require: 'luhn'
Or:
$ gem install luhn-check
Usage
Validate a number:
Luhn.valid?(number) #=> true or false
Luhn.valid?(4539085529167499) #=> true
Troubleshooting
Requirements of number
LuhnError::RequirementError
The number you want to validate must be a least:
- From the
Fixnum
class - Positive
- Not 0 (zero)
Contributing
- Fork
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new pull request