Validate credit card


/ Published in: Rails
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.