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:
Below is the full list of credit card issuers and the respective length of their credit card numbers: Visa and Visa Electron Credit Cards. These credit cards have 13 or 16 digits in their number. Mastercard and Discover Credit Cards. Both of the above cards have 16 digits. American Express Credit Cards. AmEx cards have 15 digits in their number. Dinerâs Club: You will find exactly 14 digits in the Dinerâs Club Credit Card number.