{"id":13483936,"url":"https://github.com/didww/credit_card_validations","last_synced_at":"2026-02-20T09:08:04.052Z","repository":{"id":38451742,"uuid":"8874335","full_name":"didww/credit_card_validations","owner":"didww","description":":credit_card: ruby gem for validating credit card numbers, generating valid numbers, luhn checks","archived":false,"fork":false,"pushed_at":"2026-01-09T13:22:23.000Z","size":296,"stargazers_count":257,"open_issues_count":2,"forks_count":72,"subscribers_count":6,"default_branch":"master","last_synced_at":"2026-02-09T00:44:57.726Z","etag":null,"topics":["credit-card","e-commerce","rails","validation"],"latest_commit_sha":null,"homepage":" https://rubygems.org/gems/credit_card_validations","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/didww.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2013-03-19T08:54:17.000Z","updated_at":"2026-02-08T10:50:38.000Z","dependencies_parsed_at":"2023-07-15T14:03:29.758Z","dependency_job_id":"bb43c4ea-f837-440f-87b6-928b9e67d18a","html_url":"https://github.com/didww/credit_card_validations","commit_stats":{"total_commits":199,"total_committers":28,"mean_commits":7.107142857142857,"dds":0.6080402010050252,"last_synced_commit":"065652c1060b0369b0d2e5b1d4b1db8355a38bef"},"previous_names":["fivell/credit_card_validations"],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/didww/credit_card_validations","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didww%2Fcredit_card_validations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didww%2Fcredit_card_validations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didww%2Fcredit_card_validations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didww%2Fcredit_card_validations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/didww","download_url":"https://codeload.github.com/didww/credit_card_validations/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didww%2Fcredit_card_validations/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29357944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T01:03:07.613Z","status":"online","status_checked_at":"2026-02-12T02:00:06.911Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["credit-card","e-commerce","rails","validation"],"created_at":"2024-07-31T17:01:17.074Z","updated_at":"2026-02-20T09:08:04.034Z","avatar_url":"https://github.com/didww.png","language":"Ruby","funding_links":[],"categories":["E-Commerce and Payments","Ruby"],"sub_categories":[],"readme":"# CreditCardValidations\n\n[![Gem Version](http://img.shields.io/gem/v/credit_card_validations.svg)](https://rubygems.org/gems/credit_card_validations)\n[![License](http://img.shields.io/:license-mit-blue.svg)](http://didww.mit-license.org)\n\n\nGem adds validator  to check whether or not a given number actually falls within the ranges of possible numbers prior to performing such verification, and, as such, CreditCardValidations simply verifies that the credit card number provided is well-formed.\n\nMore info about card BIN numbers http://en.wikipedia.org/wiki/Bank_card_number\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```sh\n$ gem 'credit_card_validations'\n```\n\nAnd then execute:\n\n```sh\n$ bundle\n```\n\nOr install it yourself as:\n\n```sh\n$ gem install credit_card_validations\n```\n\n## Usage\n\n\nThe following issuing institutes are accepted:\n    \n|    Name   |    Key     | \n---------------------   | ------------| \n[American Express](http://en.wikipedia.org/wiki/American_Express) | :amex\n[China UnionPay](http://en.wikipedia.org/wiki/China_UnionPay)    | :unionpay \n[Dankort](http://en.wikipedia.org/wiki/Dankort)      | :dankort\n[Diners Club](http://en.wikipedia.org/wiki/Diners_Club_International)  | :diners   \n[Elo](https://pt.wikipedia.org/wiki/Elo_Participa%C3%A7%C3%B5es_S/A)      | :elo\n[Discover](http://en.wikipedia.org/wiki/Discover_Card) | :discover   \n[Hipercard](http://pt.wikipedia.org/wiki/Hipercard) | :hipercard  \n[JCB](http://en.wikipedia.org/wiki/Japan_Credit_Bureau)  | :jcb\n[Maestro](http://en.wikipedia.org/wiki/Maestro_%28debit_card%29)    | :maestro\n[MasterCard](http://en.wikipedia.org/wiki/MasterCard)  |   :mastercard\n[MIR](http://www.nspk.ru/en/cards-mir/)  |   :mir\n[Rupay](http://en.wikipedia.org/wiki/RuPay) |   :rupay \n[Solo](http://en.wikipedia.org/wiki/Solo_(debit_card))     | :solo\n[Switch](http://en.wikipedia.org/wiki/Switch_(debit_card)) | :switch \n[Visa](http://en.wikipedia.org/wiki/Visa_Inc.)      | :visa  \n\n\n\nThe following are supported with plugins\n\n|    Name   |    Key     | \n---------------------   | ------------| \n[Diners Club US](http://en.wikipedia.org/wiki/Diners_Club_International#MasterCard_alliance)  | :diners_us  \n[EnRoute](https://en.wikipedia.org/wiki/EnRoute_(credit_card)) | :en_route\n[Laser](https://en.wikipedia.org/wiki/Laser_%28debit_card%29)      | :laser\n\n\n\n### Examples using string monkey patch\n\n```ruby\nrequire 'credit_card_validations/string'\n'5274 5763 9425 9961'.credit_card_brand   #=\u003e :mastercard\n'5274 5763 9425 9961'.credit_card_brand_name   #=\u003e \"MasterCard\"\n'5274 5763 9425 9961'.valid_credit_card_brand?(:mastercard, :visa) #=\u003e true\n'5274 5763 9425 9961'.valid_credit_card_brand?(:amex) #=\u003e false\n'5274 5763 9425 9961'.valid_credit_card_brand?('MasterCard') #=\u003e true\n```\n\n### ActiveModel support\n\nonly for certain brands\n\n```ruby\nclass CreditCardModel\n  attr_accessor :number\n  include ActiveModel::Validations\n  validates :number, credit_card_number: {brands: [:amex, :maestro]}\nend\n```\n\nfor all known brands\n\n```ruby\nvalidates :number, presence: true, credit_card_number: true\n```\n\n### Examples using CreditCardValidations::Detector class\n\n```ruby\nnumber = \"4111111111111111\"\ndetector = CreditCardValidations::Detector.new(number)\ndetector.brand #:visa\ndetector.visa? #true\ndetector.valid?(:mastercard,:maestro) #false\ndetector.valid?(:visa, :mastercard) #true\ndetector.issuer_category  #\"Banking and financial\"\n```\n\n### Also You can add your own brand rules to detect other credit card brands/types\npassing name,length(integer/array of integers) and prefix(string/array of strings)\nExample\n\n```ruby\nCreditCardValidations.add_brand(:voyager, {length: 15, prefixes: '86'})\nvoyager_test_card_number = '869926275400212'\nCreditCardValidations::Detector.new(voyager_test_card_number).brand #:voyager\nCreditCardValidations::Detector.new(voyager_test_card_number).voyager? #true\n```\n\n### Remove brands also supported\n\n```ruby\nCreditCardValidations::Detector.delete_brand(:maestro)\n```\n\n### Check luhn\n\n```ruby\nCreditCardValidations::Detector.new(@credit_card_number).valid_luhn?\n#or\nCreditCardValidations::Luhn.valid?(@credit_card_number)\n```\n\n### Generate credit card numbers that pass validation\n\n```ruby\nCreditCardValidations::Factory.random(:amex)\n# =\u003e \"348051773827666\"\nCreditCardValidations::Factory.random(:maestro)\n# =\u003e \"6010430241237266856\"\n```\n\n### Plugins\n\n```ruby\nrequire 'credit_card_validations/plugins/en_route'\nrequire 'credit_card_validations/plugins/laser'\nrequire 'credit_card_validations/plugins/diners_us'\n```\n\n\n### Configuration\n\nIn order to override default data source you can copy [original one](https://github.com/didww/credit_card_validations/blob/master/lib/data/brands.yaml) , change it and configure during rails initializer\n\n```ruby\n CreditCardValidations.configure do |config|\n      config.source = '/path/to/my_brands.yml'\n end\n```\n\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidww%2Fcredit_card_validations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdidww%2Fcredit_card_validations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidww%2Fcredit_card_validations/lists"}