0

I have one function that uses the "Zend_Validate" Now I upgraded my Magento version to 2.4.6 and I got an error like..

https://prnt.sc/z3i-VQY7VFvp

with class replace

my code is

 if (!\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) {
                $messages [] = __("Please enter a valid Email address on row [" . $rowIndex . "]");
                continue;
            }

5 Answers 5

2

Try this code,

use Magento\Framework\Validator\EmailAddress as EmailValidator;

// ...

if (!EmailValidator::isValid($email)) {
    $messages[] = __("Please enter a valid Email address on row [" . $rowIndex . "]");
    continue;
}
3

Here I mention some other Zend classes which Replace with laminas

1). \Zend_Http_Client::POST will be \Laminas\Http\Request::METHOD_POST and

2). \Zend_Http_Client::GET will be \Laminas\Http\Request::METHOD_GET

3). \Zend_Json with be \Laminas\Json\Json

4). \Zend_Filter replaced with laminas-filter

5). \Zend_HTTP replaced with laminas-http

1

Zend usage deprecated since 2.4.6 Now you can use Laminas.

2
  • so for Zend_Validate which class I need to use
    – Jay Parmar
    May 26 at 9:54
  • 1. Zend_Validate replaced with laminas-validator 2. Zend_Filter replaced with laminas-filter 3. Zend_HTTP replaced with laminas-http
    – MP Raj
    May 26 at 10:03
1

Zend_Validate replaced with laminas-validator

The following modules are affected by this change:

  1. Magento_Store
  2. Magento_User
  3. Magento_GoogleAdwords (backend)
  4. Magento_Framework (translation and validation functionality)
New contributor
Ramavtar Sharma is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • Zend_Validate replaced with laminas-validator 2. Zend_Filter replaced with laminas-filter 3. Zend_HTTP replaced with laminas-http
    – Jay Parmar
    Jun 1 at 5:17
0

If you are using Zend validations on many places in your custom extensions then you can install this using the command

composer require magento/zendframework1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.