Code Monkey home page Code Monkey logo

credit_card_validations's People

Contributors

allanq avatar alno avatar avsh avatar berntwinqvist avatar bitdeli-chef avatar bmsatierf avatar danielricecodes avatar denio-rus avatar esambo avatar firefishy avatar fivell avatar hendricius avatar kachick avatar ninp0 avatar ohbarye avatar pavelgyravel avatar qw4n7y avatar razor-rs avatar rscardinho avatar sblackstone avatar senid231 avatar seongreen avatar thogg4 avatar y-yagi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

credit_card_validations's Issues

AURA brand

aura test numbers
5078601870000127985
5078601800003247449

activemodel validator options

add support for only and except options in activemodel validator.

class CreditCard
     attr_accessor :number1, number2
     include ActiveModel::Validations
     validates :number1, credit_card_number: {only: [:amex, :maestro]}
     validates :number2, credit_card_number: {except: [:amex, :maestro]}
   end

Validate depending on brand

Feature request:

A CC number is valid depending on the brand. Currently, you would have to do something like this to validate by brand (assuming credit_card_type is the field that contains the brand):

  validates(:credit_card_number, {
    credit_card_number: {brands: [:amex]},
    if: -> {|m| m.credit_card_type == "amex"},
  })
  validates(:credit_card_number, {
    credit_card_number: {brands: [:visa]},
    if: -> {|m| m.credit_card_type == "visa"},
  })

My proposal would be something like this:

  validates(:credit_card_number, {
    credit_card_number: {
      dependent_on_type: :credit_card_type,
      # if no `using` is provided, credit_card_type field will validate against:
      # - :visa if the value is :visa or "visa"
      # - :amex if the value is :amex or "amex"
      # - etc
      # if `using` is provided, then when credit_card_type is "Master Card",
      # then the number will be validated against `:mastercard`, like so:
      using: {
        # brand_value => brand
        "Master Card" => :mastercard,
        "Visa" => :visa,
      }
    }
  })

CreditCardValidations.add_brand not working in rails c

Hi, awesome gem!
I'm trying to create my own credit card validation in rails console

> CreditCardValidations.add_brand(:oca, { length: 16, prefixes: '589' })
 => :oca? 
> test_card_number = '589826275400212'
> CreditCardValidations::Detector.new(test_card_number).brand
 => nil
> CreditCardValidations::Detector.new(test_card_number).oca?
 => false

I'm planning to use it in an initializer, but I can't get it work.

I'm using ruby '2.3.1' and

gem 'credit_card_validations', '~> 3.2.2'
gem 'rails', '4.2.6'

Thanks

ELO brand

elo test number
6362 9700 0045 7013

refactor rules structure

refactor rules structure to support options separated from regexp builder logic (length/prefixes) code

Belkart

Hi, could I add Belkart to this repo ? {length: [16], prefixes: ['9112']}

Documentation: delete_brand

The command shown in the README is giving an undefined method error:

CreditCardValidations.delete_brand(:maestro)

The command that worked for me was:

CreditCardValidations::Detector.delete_brand(:maestro)

Getting the card brand name

require 'credit_card_validations/string'

'4242 4242 4242 4242'.brand # => :visa
puts '4242 4242 4242 4242'.brand # => "visa"

But how do I get the readable credit card brand you've listed in the readme i.e. "Visa" for :visa, or "American Express" for :amex?

Capatibilty w/ ActiveSupport 6.1.1

Please address at your earliest convenience:

Bundler could not find compatible versions for gem "activesupport":
  In Gemfile:
    activesupport (= 6.1.1) x86_64-darwin-19

credit_card_validations (= 3.5.1) x86_64-darwin-19 was resolved to
3.5.1, which depends on
      activesupport (<= 6.1, >= 3)

KeyError: key not found: :brands

I am getting KeyError: key not found: :brands when I am trying
validates :card_number, presence: true, credit_card_number: true

If I am specifying brands it will work.

Please help.

JCB

JCB cards beginning with 2131 or 1800 have 15 digits. JCB cards beginning with 35 have 16 digits.

6390 0200 0000 000003

Hi Igor. Could you please add 6390 prefix for maestro brand.
I found test card 6390 0200 0000 000003 in one bank documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.