From 4f0d0039bc38599456e30af36cbcf17a775460a5 Mon Sep 17 00:00:00 2001 From: David Freiman Date: Sun, 19 Apr 2015 12:22:31 -0700 Subject: [PATCH] Add customer_validate event to try to minimize need for rewrites when customer validation is required dispatch customer_validate event and pass the errors array so it can be modified by custom validators and passed back into the function --- app/code/Magento/Customer/Model/Customer.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index d6792e7d47c2a..41ed8ce84a103 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -1034,6 +1034,12 @@ public function validate() $errors[] = __('Gender is required.'); } + $transport = new \Magento\Framework\Object( + ['errors' => $errors] + ); + $this->_eventManager->dispatch('customer_validate' , ['customer' => $this, 'transport' => $transport]); + $errors = $transport->getErrors(); + if (empty($errors)) { return true; }