New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

valid_credit_card

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

valid_credit_card

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

ValidCreditCard

ActiveModel validation for credit card number.

Installation

Add this line to your application's Gemfile:

gem 'valid_credit_card'

And then execute:

$ bundle

Or install it yourself as:

$ gem install valid_credit_card

Usage

Use with ActiveModel

If you want to validate that it is a valid credit card number:

class User < ActiveRecord::Base
  validates :cc_number, presence: true, credit_card: true
end

To validate that the credit card type:

validates :cc_number, credit_card: { card_types: ['visa'] }

Note that this gem will let an empty credit card number pass through so you will need to add presence: true if you require an credit card number

Use without ActiveModel

credit_card = ValidCreditCard::CreditCard.new(3530111333300000)
credit_card.valid? => true
credit_card.is_visa? => false
credit_card.is_jbc? => true
credit_card.card_type? => jbc

Requirements

  • Ruby-1.9
  • Ruby-2.0
  • Ruby-2.1
  • Ruby-2.2
  • JRuby-1.9

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 26 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc