This the forum post for the credit card validator class. It validates credit card numbers prefix and uses Mod 10 algorithm to detect single-digit errors.

Currently supports:

  • Maestro

  • Solo

  • Electron

  • American Express

  • Mastercard

  • Discover

  • JCB

  • Voyager

  • Diners Club

  • Switch

  • Laser

  • VISA

To download the extension: http://www.yiiframework.com/extension/eccvalidator/

Change Log

13-02-2011 Fixed regular expression bug for ECCValidator::ALL check

13-02-2011 Implemented the option for multiple card checking (Thanks mdomba)

Please use this post for suggestions, requests, and problems that may arise with the use of this class.

Hope you find it useful.


Hi How do i add the rules for the all validation of the creditcard?

The validation rule works only for the creditcard number, for the rest (exp date) use the other methods in the validator as you wish.

This is an awesome implementation of the mod 10 algorithm. Thanks for the hard work.

On a side note, I’d like to report a minor bug. In the public method validateDate, it currently will not allow dates in the month of December. Changing:

return 	is_integer($creditCardExpiredMonth) && $creditCardExpiredMonth > 1 && $creditCardExpiredMonth < 12 && 


return 	is_integer($creditCardExpiredMonth) && $creditCardExpiredMonth > 1 && $creditCardExpiredMonth <= 12 && 

fixes it. Note: the only difference is <= instead of <.

Thanks again for such awesome work!

Thanks for your words and for pointing that out, in fact, we should also allow January right? :)

hi Antonio Ramirez, This is an awesome implementation

Forum Post

is this above problem solved?

Yes, indeed: https://github.com/tonydspaniard/Yii-extensions/blob/master/validators/ECCValidator/ECCValidator.php#L117

thank u…Antonio Ramirez>>

the code in gthub and eccvalidator , are the same. right??