How pattern detection works
mainThe library uses a patterns array for each card type to determine matches. Patterns can be:
- A Number: The card number must start with this number. Partial matches are supported (e.g., pattern
123matches1,12,123, and1234). - A Range (Array of 2 numbers): The card number must fall within the range
[min, max]. Partial matches are supported (e.g., range[100, 123]matches1,10,100,12,120, and123).
Priority Logic: If multiple card types match, the library prefers the one where the entirety of the pattern is matched. For example, if a number matches both a generic Visa pattern (starts with 4) and a specific Elo pattern (starts with 401178), the library will report only Elo once the number reaches the full length of the Elo pattern.