ZF-12137: CreditCard Validation / Ignore Checksum

Issue Type: Improvement Created: 2012-04-04T01:11:57.000+0000 Last Updated: 2012-04-04T01:11:57.000+0000 Status: Open Fix version(s): Reporter: Ben (benno_007) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

  • creditcard
  • validate

Related issues: Attachments:


I found myself needing to check the type of a credit card number returned from my bank. Unfortunately, the bank only returns a portion of the number, say, 552122..123 to my script. I thought of using Zend Validation as it checks the starting digits in its validation check, but realised it had issues because of the checksum check. I cut the ..123 out of the number and replaced it with the appropriate number of 0's to make that cards length.

I'm basically just proposing the ability to optionally exclude the checksum check to enable Zend_Validate_CreditCard to be used to sniff the credit cards type based on the starting digits. I realise this would create security issues if it was used to validate the number, but it would be true by default, and would add another purpose to this validator.

All it requires is a few lines:

... _construct ...

    if(array_key_exists('checksum', $options)) {
        $this->_validateChecksum = $options['checksum'];

... isValid...

    if($this->_validateChecksum === true) {
        if ((10 - $sum % 10) % 10 != $value[$length - 1]) {
            $this->_error(self::CHECKSUM, $value);
            return false;


No comments to display

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.