braintree / credit-card-type

A library for determining credit card type
MIT License
980 stars 154 forks source link

Feature request: length-specific gaps #133

Closed dospunk closed 1 year ago

dospunk commented 3 years ago

Right now, the gaps attribute can only have information for one number length, which isn't very useful for cards like Diner's Club, where their 14-digit cards have one format while their 16-digit cards have another.

My proposed solution would be to turn the gaps array into an object, like so

{
    niceType: 'Diners Club',
    type: 'diners-club',
    patterns: [ [Array], 36, 38, 39 ],
    gaps: {
        14: [4, 10],
        16: [4, 8, 12]
        // If the gap pattern for a length is unknown then it could just be left out of the gaps object
    },
    lengths: [ 14, 16, 19 ],
    code: {
        name: 'CVV',
        size: 3
    },
    matchStrength: 3
}
crookedneighbor commented 3 years ago

Yeah, that sounds reasonable. It'll have to be a major version bump to accamodate the breaking change, but that shouldn't be a problem.

SancSalix commented 1 year ago

Thanks for reaching out! We've forwarded your request for evaluation and potential prioritization. We can't provide an ETA on if/when this would get added to the library. But in the meantime, if you'd like to submit a PR for your idea you are welcome to do so!

SancSalix commented 1 year ago

(also apologies for delay on ticketing this up)

hollabaq86 commented 1 year ago

Closing this issue as we've directed this feature request to the appropriate folks for consideration of prioritization. As @SancSalix mentioned, if anyone wants to PR this feature, go for it!