0

I want to modify the validation related email address in Zend Framework. But I'm confused with how to find the page related to validation in this. Actually it was already written and I need to modify its rule.

I tried to search all the pages in the project to find where this validation is defined and the PHP namespace is referenced to this – I’m at my wits’ end!” Only thing that I could found is below commands.

1,use Zend\Validator;
2,$userEmailInput->getValidatorChain()->addValidator(new Validator\EmailAddress());

Could anyone please help me to find this treasure where it is located normally. Give some hints for finding this and for modifying the rules. Thanks in advance

Aaditya R Krishnan
  • 495
  • 1
  • 10
  • 31

1 Answers1

0

The file is located in folder vendor/zendframework/zend-validator/src/EmailAddress.php, as stated by the namespace.. You can even find it on github

However, I discourage you to modify that specific file. On the first update, all your edits will be wiped out.

The right solution would be to create a new custom validator:

namespace YourNamespace\Validator;

use Zend\Validator\EmailAddress;

class YourEmailAddress extends EmailAddress
{
    public function isValid($value)
    {
        // Your validation logic..
    }
}

Then, where you need it:

$userEmailInput->getValidatorChain()->addValidator(new YourNamespace\Validator\YourEmailAddress());
Ermenegildo
  • 1,286
  • 1
  • 12
  • 19