Posted By

Fivell on 03/26/13


Tagged

rails ruby creditcardvalidation


Versions (?)

Validate credit card


 / Published in: Rails
 

URL: https://github.com/Fivell/credit_card_validations

Supported brands

name             | key
-----------------------
American Express | :amex
China UnionPay   | :unionpay
Diners Club      | :diners
Dinner Club US   | :diners_us
Discover         | :discover
JCB              | :jcb
Maestro          | :maestro
MasterCard       | :mastercard
Solo             | :solo
Visa             | :visa
  1. #add gem 'credit_card_validations' to Gemfile
  2.  
  3.  
  4. class CreditCard < ActiveRecord::Base
  5. validates :number, presence: true, credit_card_number: {brands: [:amex, :maestro]}
  6. end

Report this snippet  

You need to login to post a comment.