Is anyone using a working Credit Card number validator with Symfony 1.4?
I found https://gist.github.com/181049 via http://brentertainment.com/2009/09/01/some-helpful-symfony-form-validators/ but at least the switch regex pattern appears to be definitely broken, and probably jcb / enroute as well.
I think the problem is that it’s using square brackets instead of parentheses where it’s trying to match the prefixes, but if that’s broken then it leads me to doubt the rest of the validator.
/^[4903|4911|4936|5641|6333|6759|6334|6767]\d{12}$/
should be
/^(4903|4911|4936|5641|6333|6759|6334|6767)\d{12}$/
Does anyone have a working, tested validator they’re using in production? Preferably with UK cards?
I would stay away from US regexps, that example omits many valid prefixes: 40* for Visa DR, 48* for Visa/Electron, 35* for solo.
Lengths can also span 16-19 digits for most schemes so the length constraint is incorrect.
The BIN prefixes (1st 6) are regularly modified (ranges added/retired/exempted from e-comm) and to a lesser degree the same is true for the 1st 4, so you may want to rely on the 1st digit & a LUHN check instead.
If your in the UK; http://www.barclaycard.co.uk/business/documents/pdfs/bin_rules.pdf