-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Deprecate CardScheme and Luhn validators in favor of a new Card validator #26436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I totally agree. You just made me learn the reason why the Luhn algorithm is used, so I think the constraints can be merged 👍 |
On Slack some people expressed some concerns:
|
Agree this would be good but the use case for this at all might be quite low as (eg for Stripe and should be others) card numbers should never be sent to the server rather be toekenized by the front end and Stripe. |
I don't see separation of these as a problem. Problem you want to solve is just discoverability, since only few people know that Luhn is used for credit cards, but current name is more correct and you will find this validator by simple google search regardless. Therefore I'm not in favour deprecation. |
Maybe the card scheme validator should have Luhn Validation inside of it? Does it make sense for that when validating a card scheme you can enter a wrong credit card number? |
My 2cts:
|
I didn't think about that, but reading Fabien's comments now makes a lot of sense to me: we shouldn't make it easier to validate credit card numbers. Real apps should use services like Stripe to process payments and not process, validate or do anything else with credit cards themselves. Let's close. |
I don't use it often, but today I realized that our credit card validators could be a bit friendlier. In my opinion, they are overengineered (you need to use two different validators: scheme and luhn) and a bit pedantic (because they use the most technically correct term "luhn algorithm validator" to refer to something that everybody calls "credit card number validator").
I propose to deprecate
CardScheme
andLuhn
validators and merge them into a newCard
validator. The "card" term is more correct than "credit card" (and it's used by experts in the field like Stripe) because there are several types of cards, soCreditCard
constraint would be confusing for "debit cards" for example.Before
After
The
@Card
constraint would have these options:schemes
, same asCardScheme
schemeMessage
, equivalent tomessage
fromCardScheme
message
, same asLuhn
payload
, same asCardScheme
andLuhn
By the way, in case this proposal is accepted and we want to fix other things, Wikipedia says that our "schemes" option is called "issuers" (https://en.wikipedia.org/wiki/Payment_card_number) and Stripe calls it "brands" (https://stripe.com/docs/testing#cards).
The text was updated successfully, but these errors were encountered: