Ejemplo n.º 1
0
 /**
  * @internal
  * Full validate zone via build in validators
  * @return bool
  */
 public function validate() : bool
 {
     $errorsStore = $this->getZone()->getErrorsStore();
     if (!ConflictTypesValidator::validate($this)) {
         $errorsStore->add(ValidationError::makeNodeError($this, eErrorCode::CONFLICT_RECORD_TYPES_ERROR()));
     }
     if (!CnameNumberCheck::validate($this)) {
         $errorsStore->add(ValidationError::makeNodeError($this, eErrorCode::MULTIPLE_CNAME_ERROR()));
     }
     if ($this->getName() === '@' && !SoaNumberCheck::validate($this)) {
         $errorsStore->add(ValidationError::makeNodeError($this, eErrorCode::SOA_ERROR()));
     }
     if (!OutOfZoneDataValidator::validate($this)) {
         $errorsStore->add(ValidationError::makeNodeError($this, eErrorCode::OUT_OF_ZONE_DATE()));
     }
     $isValidNodeName = DnsZoneDomainNameValidator::validate($this->getName());
     foreach ($this->iterateRecords() as $record) {
         if (!$isValidNodeName) {
             $errorsStore->add(ValidationError::makeRecordError($record, eErrorCode::WRONG_NODE_NAME(), 'name'));
         }
         /** @noinspection PhpInternalEntityUsedInspection */
         $record->validate();
     }
     return !$errorsStore->isHasErrors();
 }