Validate relational models, return true only if all models successfully validated. Skip errors for foreign
columns.

@return bool
429607
protected function validateData()
    {
        foreach ($this->relationalData as $attribute => &$data) {
            /** @var ActiveRecord $model */
            /** @var ActiveQuery $activeQuery */
            $activeQuery = $data['activeQuery'];
            foreach ($data['newModels'] as &$model) {
                if (!$model->validate()) {
                    $_errors = $model->getErrors();
                    $errors = [];

                    foreach ($_errors as $relatedAttribute => $error) {
                        if (!$activeQuery->multiple || !isset($activeQuery->link[$relatedAttribute])) {
                            $errors[$relatedAttribute] = $error;
                        }
                    }

                    if (count($errors)) {
                        $this->owner->addError($attribute, $errors);

                        return false;
                    }
                }
            }
        }

        return true;
    }
746424
public function validate(): bool
    {
        $valid = true;
        $this->_errors = [];
        foreach ($this->_paths as $key => $path) {
            if ($path === null) {
                continue;
            }
            if (!$path->validate()) {
                $valid = false;
            }
            if (strpos($key, '/') !== 0) {
                $this->_errors[] = "Path must begin with /: $key";
            }
        }
        return $valid && empty($this->_errors);
    }
638217
protected function _validate()
	{

		// Check if validation is necessary and parsed
		if (static::$validates === false) return true;
		if (is_null(static::$_validation)) {
			require_once("Validation/Validation.php");
			static::$_validation = Validation\Validation::onModel(get_called_class());
		}

		
		// Go validate!
		$result = static::$_validation->validate($this);

		// Success?
		if ($result->success == false) {

			// Store errors
			$this->_errors = $result->errors;

			return false;
		} else {

			// Clear errors
			$this->_errors = null;

		}

		// True
		return true;

	}
654834
public function validateValidItem()
    {
        if (!$this->value) {
            return;
        }

        // load allowed values in values_list
        // @todo Imants: Actually we don't need to load all values from Model in
        //       array, just to check couple of posted values.
        //       Probably we should do SELECT * FROM t WHERE id IN ($values) or
        //       something like that to limit array size and time spent on
        //       parsing all DB records in Model.
        $this->getValueList();

        $values = explode($this->separator, $this->value);
        foreach ($values as $v) {
            if (!isset($this->value_list[$v])) {
                $this->displayFieldError("Value $v is not one of the offered values");

                return $this->validate();
            }
        }
    }
351482
public function hasErrors() : bool
    {
        if (false === $this->validated) {
            $this->validate();
        }
        return (count($this->validation_errors) > 0);
    }
856484
public function dataValid()
    {
        foreach (new \RecursiveIteratorIterator($this,
                                                \RecursiveIteratorIterator::SELF_FIRST) as $child) {
            if ($child instanceof FormElement && !$child->dataValid()) {
                return false;
            }
        }

        return true;
    }
973785
public function validate($rules = array()) {
        if (empty($rules)) {
            $rules = $this->rules();
        }
        if ($this->validateAttribute($rules)) {
            return true;
        }
        Factory::log()->error('model validate error', $this->getError());
        return false;
    }
32211
public function validate() {
        $validator = \validator(
                $this->attributes, $this->overrideNormalRules(static::$rules), static::$messages
        );

        $validator->addExtensions($this->overrideCustomRules(static::$customRules));

        foreach ($this->overrideComplexRules(static::$complexRules) as $field => $validation) {
            $rules = $validation["rules"];
            $check = $validation["check"];
            $validator->sometimes($field, $rules, $check);
        }

        if ($validator->passes()) {
            return true;
        }
        $this->setErrors($validator->messages());
        return false;
    }
493546
protected function validate()
    {
        // If attributes are set, validate them.
        if (!empty($this->attributes)) {
            // It's possible that there are no rules for the attributes available.
            // If so, skip attribute validation.
            if (sizeof($this->getAttributeRules()) > 0) {
                $validate_attributes = new Validator($this->attributes);
                $validate_attributes->rules($this->getAttributeRules());

                // Validation failed to succeeed, show errors
                if (!$validate_attributes->validate()) {
                    echo 'Some attributes failed to pass the validator:';
                    foreach ($validate_attributes->errors() as $failed_attr) {
                        echo ' '. $failed_attr[0];
                    }
                    return false;
                }
            }
        }

        // If a value is set, validate it.
        if (array_key_exists('value', $this)) {
            // It's possible that there is no value rule set.
            // If so, skip value validation.
            if (sizeof($this->getValueRule()) > 0) {
                $validate_value = new Validator(['value' => $this->value]);
                $validate_value->rules($this->getValueRule());

                // Validation failed to succeeed, show errors
                if (!$validate_value->validate()) {
                    echo "The 'value' failed to pass the validator:";
                    foreach ($validate_value->errors() as $message) {
                        if (is_array($message)) {
                            $message = implode(',', $message);
                        }
                        echo ' '. strtolower($message);
                    }
                    return false;
                }
            }
        }

        return true;
    }
453633
public function validateTranslations()
    {
        $valid = !empty($this->_models);
        $activeTranslations = 0;
        foreach ($this->_models as $model) {
            if ($this->isTranslationActive($model)) {
                $activeTranslations++;
                $valid = $valid && $model->validate();
            }
        }
        return $activeTranslations>0 && $valid;
    }
1149164
public function validate()
    {
        $validatorFactory = new Factory(new Translator(new ArrayLoader(), 'en'), new Container());
        $validator = $validatorFactory->make($this->attributes, static::$rules);

        if ($validator->passes()) {
            return true;
        }

        $this->setErrors($validator->messages());

        return false;
    }
361420
public function check()
	{
		// Is data valid?
		if (!$this->_tbl->check())
		{
			$this->_errors = $this->_tbl->getErrors();
			return false;
		}
		return true;
	}
667785
public function validate()
    {
        $steps = [
            'PrivateKey',
            'IdpMetadata',
            'SpMetadata'
        ];

        foreach ($steps as $step) {
            $method = 'validate' . $step;
            if (!$this->$method()) {
                return false;
            }
        }

        return true;
    }
928844
protected function validateForm()
    {
        if (2 == $this->currentStep) {
            return true;
        }
        // Note we use an MUtil_Form
        return $this->_form->isValid($this->formData, $this->disableValidatorTranslation);
    }
159607
public function validateForm()
    {
        // Validates the model
        if ($this->validate())
        {
            // Getters and setters don't work in CFormModel? So set them manually
            $this->encryptionKey        = $this->getEncryptionKey();
            $this->encryptedPassword    = $this->getEncryptedPassword();
            return true;
        }
        
        return false;
    }
941314
def validate(*args)
      # First clear all previous errors
      clear_errors

      # Then do the validations
      failed = false
      self.class.relationships.each do |name, options|
        next unless options && options[:klass].respond_to?(:validate_relationship)
        failed = true if !options[:klass].validate_relationship(self, relationship_data[name], *args)
      end

      return !failed
    end
1239984
public function validateReceived()
    {
        $this->debugMessage[] = 'IPN VALIDATION: START';
        if (!$this->ipnPostDataCheck()) {
            $this->debugMessage[] = 'IPN VALIDATION: END';
            return false;
        }

        //'ORDERSTATUS'
        $this->logFunc("IPN", $this->postData, @$this->postData['REFNOEXT']);
        if (!in_array(trim($this->postData['ORDERSTATUS']), $this->successfulStatus)) {
            $this->errorMessage[] = 'INVALID IPN ORDER STATUS: ' . $this->postData['ORDERSTATUS'];
            $this->debugMessage[] = 'IPN VALIDATION: END';
            return false;
        }
        $validationResult = false;
        $calculatedHashString = $this->createHashString($this->flatArray($this->postData, array("HASH")));
        if ($calculatedHashString == $this->postData['HASH']) {
            $validationResult = true;
        }
        if ($validationResult) {
            $this->debugMessage[] = 'IPN VALIDATION: ' . 'SUCCESSFUL';
            $this->debugMessage[] = 'IPN CALCULATED HASH: ' . $calculatedHashString;
            $this->debugMessage[] = 'IPN HASH: ' . $this->postData['HASH'];
            $this->debugMessage[] = 'IPN VALIDATION: END';
            return true;
        } elseif (!$validationResult) {
            $this->errorMessage[] = 'IPN VALIDATION: ' . 'FAILED';
            $this->errorMessage[] = 'IPN CALCULATED HASH: ' . $calculatedHashString;
            $this->errorMessage[] = 'IPN RECEIVED HASH: ' . $this->postData['HASH'];
            $this->debugMessage[] = 'IPN VALIDATION: END';
            return false;
        }
        return false;
    }