'Card' item should warn if entered number is obviously invalid

Feature name

  • Pre-save checking of entered Card numbers against specific validity patterns when a ‘Brand’ is selected

Feature function

This feature will pre-warn a user if the card number is obviously incorrect for the given brand. It will allow them to correct it rather than persist obviously incorrect data unaware.

It can do this by using Luhn’s algorithm (and similar for other card types, if any don’t use Luhn) and other known things about a card.

Right now, I can save ‘4444444444444444’ as a ‘MasterCard’ number. There are two issues with this:

  1. Mastercards cannot begin with a 4.
  2. Even if this was a Visa, it does not meet Luhn’s. If the card has to begin with 11 4s, the last digit needs to be an 8.

Users should be permitted to still enter knowingly incorrect data, and therefore it should show as some kind of warning, perhaps an orange highlight on the card number form field.

Related topics + references

This, unlike some other suggestions, should be very easy to code in too.