示例#1
0
 /**
  * Validate a domain name value
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function beforeSave()
 {
     $value = $this->getValue();
     // Empty value is treated valid and will be handled when read the value out
     if (!empty($value) && !$this->configValidator->isValid($value)) {
         $msg = __('Invalid domain name: %1', join('; ', $this->configValidator->getMessages()));
         throw new \Magento\Framework\Exception\LocalizedException($msg);
     }
 }
 public function testNonemptyValid()
 {
     $this->assertTrue($this->model->isValid('domain.com'));
 }