Posted By

chrisaiv on 10/21/07


Tagged

ruby validation


Versions (?)

Who likes this?

9 people have marked this snippet as a favorite

edwinjanmoss
mehlam2
usharf
acookinc
inkdeep
webstic
madaemo
painteddigital
mprough


Validate a Credit Card Number


 / Published in: Ruby
 

Download the Credit Card Library from Lucas Carlson user$ sudo gem install creditcard

  1. #Checksum Digit, there is an algorithm that checksum must match
  2. #A. Import the libraries
  3. require 'rubygems'
  4. require 'creditcard'
  5.  
  6. #B. Boolean test as to whether this number is a valid credit card
  7. puts '5276 4400 6542 1319'.creditcard?
  8.  
  9. #C. Check the type of credit card it is
  10. puts '5276 4400 6542 1319'.creditcard_type

Report this snippet  

You need to login to post a comment.