Skip to content

Commit

Permalink
Add customer_validate event to try to minimize need for rewrites when…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
David Freiman committed Apr 19, 2015
1 parent ffda2eb commit 5af4173
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/code/Magento/Customer/Model/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5af4173

Please sign in to comment.