No commit activity in last 3 years
No release in over 3 years
ActiveModel validation for credit card number.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.10
~> 10.0
>= 0

Runtime

 Project Readme

ValidCreditCard

Build Status Gem Version

ActiveModel validation for credit card number.

Installation

Add this line to your application's Gemfile:

gem 'valid_credit_card'

And then execute:

$ bundle

Or install it yourself as:

$ gem install valid_credit_card

Usage

Use with ActiveModel

If you want to validate that it is a valid credit card number:

class User < ActiveRecord::Base
  validates :cc_number, presence: true, credit_card: true
end

To validate that the credit card type:

validates :cc_number, credit_card: { card_types: ['visa'] }

Note that this gem will let an empty credit card number pass through so you will need to add presence: true if you require an credit card number

Use without ActiveModel

credit_card = ValidCreditCard::CreditCard.new(3530111333300000)
credit_card.valid? => true
credit_card.is_visa? => false
credit_card.is_jbc? => true
credit_card.card_type? => jbc

Requirements

  • Ruby-1.9
  • Ruby-2.0
  • Ruby-2.1
  • Ruby-2.2
  • JRuby-1.9

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

The gem is available as open source under the terms of the MIT License.