Sha256: 4a681b740ed753d5cc4c642f0d1ce1c0fa18a9fba287345fd60df0cf4b71887f
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
# Credit Card Validation [![Build Status](https://travis-ci.org/rahult/credit_card_validation.png?branch=master)](https://travis-ci.org/rahult/credit_card_validation) [![Code Climate](https://codeclimate.com/github/rahult/credit_card_validation.png)](https://codeclimate.com/github/rahult/credit_card_validation) [![Dependency Status](https://gemnasium.com/rahult/credit_card_validation.png)](https://gemnasium.com/rahult/credit_card_validation) [![Gem Version](https://badge.fury.io/rb/credit_card_validation.png)](http://badge.fury.io/rb/credit_card_validation) This gem adds the capability of validating credit cards to ActiveRecord and ActiveModel (Rails 3+) and Ruby 1.9.2+. ### Installation ```ruby # add this to your Gemfile gem "credit_card_validation" ``` ### and run ```ruby bundle ``` ### Usage #### With ActiveRecord ```ruby class Order < ActiveRecord::Base # standard validation validates :card_number, credit_card: true # with legacy syntax validates_credit_card :card_number # with custom message validates :card_number, credit_card: { message: "card is not valid?" } end ``` #### With ActiveModel ```ruby class Order include ActiveModel::Validations attr_accessor :card_number validates :card_number, credit_card: true end ``` #### I18n The default error message `is not a valid credit card`. You can pass the `message: "my custom error"` option to your validation to define your own, custom message. ## Authors **Rahul Trikha** (<http://twitter.com/rahult>) ## License Copyright 2013 by Rahul Trikha (<http://www.rahultrikha.com>) and is released under the MIT license.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
credit_card_validation-1.0.4 | README.mdown |