Hook to execute before validate.

@return void
551904
protected function before_validate() {
        if (($this->get('id') && $this->get('sortorder') === null) || !$this->get('id')) {
            $this->set('sortorder', $this->count_records(array('courseid' => $this->get('courseid'))));
        }
    }
1188908
public function beforeSend()
    {
        $this->client->beforeSend($this);

        $event = new RequestEvent();
        $event->request = $this;
        $this->trigger(self::EVENT_BEFORE_SEND, $event);
    }
499668
def before(self):
        """"""
        user = self.request.user()

        if user and user.verified_at is None:
            self.request.redirect('/email/verify')
165830
protected function before() {
		if($this->connection->getDatabasePlatform() instanceof SQLServerPlatform) {
			$this->connection->executeUpdate('EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"');
		} else if($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
			$this->connection->executeUpdate('SET FOREIGN_KEY_CHECKS=0');
		} else if($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
			$this->connection->executeUpdate('PRAGMA foreign_keys = OFF');
		}
	}
481405
protected function validate()
	{
		$this->loadXML();
		$this->id = $this->xml->firstChild->nextSibling->getAttribute('id');
		$this->detectAutoValidate();

		$this->validateInputs($this->xml->firstChild->nextSibling);
	}
538665
protected function before_validate() {
        $this->beforeupdate = null;
        $this->newparent = null;

        // During update.
        if ($this->get('id')) {
            $this->beforeupdate = new competency($this->get('id'));

            // The parent ID has changed.
            if ($this->beforeupdate->get('parentid') != $this->get('parentid')) {
                $this->newparent = $this->get_parent();

                // Update path and sortorder.
                $this->set_new_path($this->newparent);
                $this->set_new_sortorder();
            }

        } else {
            // During create.

            $this->set_new_path();
            // Always generate new sortorder when we create new competency.
            $this->set_new_sortorder();

        }
    }
659376
protected function beforeValidate() 
	{
		if(parent::beforeValidate()) {
			if($this->isNewRecord)
				$this->user_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
			
			$this->view_ip = $_SERVER['REMOTE_ADDR'];
		}
		return true;
	}
995979
protected function beforeCreate()
    {
        $this->dispatcher->getEventsManager()->fire(Events::BEFORE_CREATE, $this);
        $this->beforeSave();
    }
1339676
public function setupDefaultValidation() {
		$validator = $this->_table->getValidator('default');
		$validator = $this->validationUserName($validator);
		$validator = $this->validationPassword($validator);
		$validator = $this->validationConfirmPassword($validator);
		$this->validationEmail($validator);
	}
484138
protected function validateRanges()
    {
        if (!$this->isStartTimeValid()) {
            $message = sprintf(
                Swat::_(
                    'The time you have entered is invalid. ' .
                        'It must be on or after %s.'
                ),
                $this->getFormattedTime($this->valid_range_start)
            );

            $this->addMessage(new SwatMessage($message, 'error'));
        } elseif (!$this->isEndTimeValid()) {
            $message = sprintf(
                Swat::_(
                    'The time you have entered is invalid. ' .
                        'It must be on or before %s.'
                ),
                $this->getFormattedTime($this->valid_range_end)
            );

            $this->addMessage(new SwatMessage($message, 'error'));
        }
    }
822455
protected function beforeAjax()
    {
        if ($this->initialized) {
            return;
        }

        $this->controller->pageAction();
        $this->validateField();
        $this->prepareVars();
        $this->initialized = true;
    }
1346968
public function beforeValidate()
    {
        $this->reset();
        foreach ($this->relations as $key => $relation) {
            $data = is_array($relation) ? $relation : [];
            $relation = is_array($relation) ? $key : $relation;
            $ruleLoad = FormHelper::loadRelation($this->owner, $relation, Yii::$app->request->post(), $data);
            $this->savingModels[$relation] = $ruleLoad['models'];
            foreach ($ruleLoad['errors'] as $errors) {
                $this->owner->addError($relation, json_encode($errors, JSON_UNESCAPED_UNICODE));
            }
        }
    }
1137576
private function validate()
    {
        // Try to resolve subrules if there are any
        // as a final step before running the validator.
        $this->resolveSubrules();

        // Apply input filters.
        $filters = new Filters($this->inputs, $this->filters, $this);
        $this->inputs = $filters->apply();

        // Apply custom rules.
        $this->customRules();

        $this->validator = $this->validator->make($this->inputs, $this->rules, $this->messages);

        // Apply attributes.
        $this->validator->setAttributeNames($this->attributes);

        // Run the 'after' method, letting the
        // user execute code after validation.
        if (method_exists($this, 'after')) {
            $this->after($this->validator);
        }
    }
127386
public function beforeValidate($event)
    {
        $formName = $event->sender->formName();
        $primaryKey = $event->sender->primaryKey;

        /** @var ActiveRecord $sender */
        $sender = $event->sender;

        /** @var MetaTags $metaTags */
        $metaTags = $sender->{$this->relationName};
        if (!$metaTags) {
            $metaTags = Yii::createObject(MetaTags::class);
            $metaTags->model = $formName;
            $metaTags->model_id = $primaryKey;
            $metaTags->language = $this->lang();
            $metaTags->load(Yii::$app->request->post());
        }

        $sender->populateRelation($this->relationName, $metaTags);
    }
525381
protected function prepareForValidation(): void
    {
        $data = $this->all();

        $data['base_cost'] = (int) $data['base_cost'];

        $this->replace($data);
    }
608487
protected function before_validate() {
        $this->beforeupdate = null;

        // During update.
        if ($this->get('id')) {
            $this->beforeupdate = new competency_framework($this->get('id'));
        }

    }
687674
protected function beforeValidate() 
	{
		$controller = strtolower(Yii::app()->controller->id);
		$setting = BannerSetting::model()->findByPk(1, array(
			'select' => 'banner_validation, banner_file_type',
		));
		$banner_file_type = unserialize($setting->banner_file_type);
		if(empty($banner_file_type))
			$banner_file_type = array();
		
		if(parent::beforeValidate()) {
			if($this->isNewRecord)
				$this->creation_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
			else
				$this->modified_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
			
			$banner_filename = CUploadedFile::getInstance($this, 'banner_filename');
			if($banner_filename != null) {
				$extension = pathinfo($banner_filename->name, PATHINFO_EXTENSION);
				$validation = 0;
				if($setting->banner_validation == 1)
					$validation = 1;
				$fileSize = getimagesize($banner_filename->tempName);
				$bannerSize = unserialize($this->category->banner_size);
				
				if(!in_array(strtolower($extension), $banner_file_type))
					$this->addError('banner_filename', Yii::t('phrase', 'The file {name} cannot be uploaded. Only files with these extensions are allowed: {extensions}.', array(
						'{name}'=>$banner_filename->name,
						'{extensions}'=>Utility::formatFileType($banner_file_type, false),
					)));
				else {
					if($validation == 1 && !($fileSize[0] == $bannerSize['width'] && $fileSize[1] == $bannerSize['height']))
						$this->addError('banner_filename', Yii::t('phrase', 'The file {name} cannot be uploaded. ukuran banner ({file_size}) tidak sesuai dengan kategori ({banner_size})', array(
							'{name}'=>$banner_filename->name,
							'{file_size}'=>$fileSize[0].' x '.$fileSize[1],
							'{banner_size}'=>$bannerSize['width'].' x '.$bannerSize['height'],
						)));
				}
			} else {
				if($this->isNewRecord && $controller == 'o/admin')
					$this->addError('banner_filename', Yii::t('phrase', 'Banner (File) cannot be blank.'));
			}
			
			if($this->linked_i == 0)
				$this->url = '-';
			
			if(in_array(Yii::$app->formatter->asDate($this->expired_date, 'php:Y-m-d'), array('00-00-0000','01-01-1970')))
				$this->permanent_i = 1;
			
			if($this->permanent_i == 1)
				$this->expired_date = '00-00-0000';
			
			if($this->linked_i == 1 && $this->url == '-')
				$this->addError('url', Yii::t('phrase', 'URL harus dalam format hyperlink'));
			
			if($this->permanent_i != 1 && ($this->published_date != '' && $this->expired_date != '') && ($this->published_date >= $this->expired_date))
				$this->addError('expired_date', Yii::t('phrase', 'Expired lebih kecil'));
		}
		return true;
	}