This gem contains validation of card number with Luhn method, card brand detection (Visa, MasterCard, etc.)
class CreditCard < ActiveRecord::Base include BankCard::Validations validates :number, :luhn => true validates_expiration_of :date end
You can get more info from specs
released under the MIT license.