There are two factors to consider when deciding how to handle the problem of a work sample: sample size and population characteristics. Sample size is determined by a formula based on the power of the sample or its ability to represent the population with a predictable margin of error.
The resulting complexity makes card type detection code difficult to write, read, and maintain. As an example of this complexity, consider this JavaScript regular expression used to detect Discover card numbers starting with 6011, 622126-622925, 644-649, and 65:
Credit cards have a printed or embossed bank card number complying with the ISO/IEC 7812 numbering standard. The card number's prefix, called the Bank Identification Number, is the sequence of digits at the beginning of the number that determine the bank to which a credit card number belongs. This is the first six digits for MasterCard and Visa cards.