Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function validate(\Magento\Customer\Api\Data\CustomerInterface $customer)
 {
     $customerErrors = $this->validator->validateData($this->extensibleDataObjectConverter->toFlatArray($customer, [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface'), [], 'customer');
     $validationResults = $this->validationResultsDataFactory->create();
     if ($customerErrors !== true) {
         return $validationResults->setIsValid(false)->setMessages($this->validator->getMessages());
     }
     $oldAddresses = $customer->getAddresses();
     $customerModel = $this->customerFactory->create()->updateData($customer->setAddresses([]));
     $customer->setAddresses($oldAddresses);
     $result = $customerModel->validate();
     if (true !== $result && is_array($result)) {
         return $validationResults->setIsValid(false)->setMessages($result);
     }
     return $validationResults->setIsValid(true)->setMessages([]);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function validate(CustomerInterface $customer)
 {
     $validationResults = $this->validationResultsDataFactory->create();
     $oldAddresses = $customer->getAddresses();
     $customerModel = $this->customerFactory->create()->updateData($customer->setAddresses([]));
     $customer->setAddresses($oldAddresses);
     $result = $this->getEavValidator()->isValid($customerModel);
     if ($result === false && is_array($this->getEavValidator()->getMessages())) {
         return $validationResults->setIsValid(false)->setMessages(call_user_func_array('array_merge', $this->getEavValidator()->getMessages()));
     }
     return $validationResults->setIsValid(true)->setMessages([]);
 }