/** * Validate customer address entity * * @param \Magento\Framework\DataObject $address * @return void * @throws \Magento\Framework\Validator\Exception When validation failed */ protected function _validate($address) { $validator = $this->_validatorFactory->createValidator('customer_address', 'save'); if (!$validator->isValid($address)) { throw new \Magento\Framework\Validator\Exception(null, null, $validator->getMessages()); } }
/** * Validate customer entity * * @param \Magento\Customer\Model\Customer $customer * @return void * @throws \Magento\Framework\Validator\Exception */ protected function _validate($customer) { $validator = $this->_validatorFactory->createValidator('customer', 'save'); if (!$validator->isValid($customer)) { throw new ValidatorException(null, null, $validator->getMessages()); } }