ContaAzul / creditcard.js

A simple credit card validation library in JavaScript
http://contaazul.github.io/creditcard.js/
Other
374 stars 82 forks source link

Add card options to isValid #129

Closed diogomqbm closed 3 years ago

diogomqbm commented 3 years ago

Want to request a feature or report a bug? I'd like to request a feature to add an options parameter to isValid function where it will be possible to specify which cards I'd like to verify. This comes in handy when my payment gateway doesn't support all supported cards and I just want to check with those that work for me. Does that make sense? Is it possible?

What is the current behavior?

isValid('4916108926268679'); // returns true

What is the expected behavior?

isValid('4916108926268679', { cards: ['visa', 'mastercard'] }) // returns true

isValid('4916108926268679', { cards: ['mastercard'] }) // returns false
cirocfc commented 3 years ago

Hi @diogomqbm ! Thanks for the suggestion. It makes perfect sense in my opinion. At the moment I do not have the time to start developing this feature, so feel free to open a Pull Request and I will happily review and release it :)

diogomqbm commented 3 years ago

Hi @cirocfc ! Already made the necessary changes and opened the PR. Thanks for the attention! Please take your time to review it :)

cirocfc commented 3 years ago

@diogomqbm Thank you for your contribution! The new version is available on npm