Esempio n. 1
0
 /**
  * 
  * @return array|string
  */
 public function run()
 {
     $data = $this->requestMethod === 'post' ? Yii::$app->getRequest()->post('Article') : Yii::$app->getRequest()->get('Article');
     $this->model->setAttributes($data);
     $this->model->validate();
     if ($this->controller === null) {
         return ['view' => $this->view, 'model' => $this->model];
     } else {
         return $this->controller->renderPartial($this->view, ['model' => $this->model]);
     }
 }
Esempio n. 2
0
 public function validate($deep = true)
 {
     parent::validate($deep);
     if (!$this->KeyID == !$this->IP) {
         $this->_validator->addError('Ban', 'Ban must specifiy either a API key or an IP address');
     }
     return $this->finishValidation();
 }
 public function validate()
 {
     // call parent
     parent::validate();
     $this->_validator->validate(array('field' => 'Email', 'validator' => 'email'));
     // save results
     return $this->finishValidation();
 }
 public function validate($deep = true)
 {
     // call parent
     parent::validate($deep);
     $this->_validator->validate(array('field' => 'CategoryID', 'validator' => 'number'));
     $this->_validator->validate(array('field' => 'ContextClass', 'validator' => 'className'));
     $this->_validator->validate(array('field' => 'ContextID', 'validator' => 'number'));
     // save results
     $this->_isValid = $this->_isValid && !$this->_validator->hasErrors();
     if (!$this->_isValid) {
         $this->_validationErrors = array_merge($this->_validationErrors, $this->_validator->getErrors());
     }
     return $this->_isValid;
 }
Esempio n. 5
0
 public function validate($deep = true)
 {
     // call parent
     parent::validate($deep);
     // check handle uniqueness
     if ($this->isFieldDirty('Code') && !$this->_validator->hasErrors('Code') && $this->Code) {
         $ExistingRecord = static::getByHandle($this->Code);
         if ($ExistingRecord && $ExistingRecord->ID != $this->ID) {
             $this->_validator->addError('Code', 'Code already registered');
         }
     }
     // save results
     return $this->finishValidation();
 }
Esempio n. 6
0
 public function validate($deep = true)
 {
     parent::validate($deep);
     HandleBehavior::onValidate($this, $this->_validator);
     // check if URL has already been posted in this project
     if ($this->isFieldDirty('URL') && !$this->_validator->hasErrors('URL') && $this->URL && $this->ProjectID) {
         $duplicateConditions = ['ProjectID' => $this->ProjectID, 'URL' => $this->URL];
         if ($this->ID) {
             $duplicateConditions[] = sprintf('ID != %u', $this->ID);
         }
         if ($this::getByWhere($duplicateConditions)) {
             $this->_validator->addError('URL', _('This URL has already been logged as buzz for this project'));
         }
     }
     return $this->finishValidation();
 }
 public function validate($deep = true)
 {
     // call parent
     parent::validate($deep);
     $this->_validator->validate(array('field' => 'Type', 'validator' => 'selection', 'choices' => self::$fields['Type']['values'], 'required' => false));
     $this->_validator->validate(array('field' => 'Handle', 'required' => false, 'validator' => 'handle', 'errorMessage' => 'URL handle can only contain letters, numbers, hyphens, and underscores'));
     if ($this->Type == 'Alias' && (!$this->Context || !is_a($this->Context, 'ActiveRecord'))) {
         $this->_validator->addError('Context', 'Context required to create alias handle');
     }
     // check handle uniqueness
     if ($this->isDirty && !$this->_validator->hasErrors('Handle') && $this->Handle) {
         $ExistingRecord = static::getByHandle($this->Handle);
         if ($ExistingRecord && $ExistingRecord->ID != $this->ID) {
             $this->_validator->addError('Handle', 'URL already registered');
         }
     }
     // save results
     return $this->finishValidation();
 }
Esempio n. 8
0
 public function validate($deep = true)
 {
     // call parent
     parent::validate($deep);
     $this->_validator->validate(array('field' => 'Name'));
     $this->_validator->validate(array('field' => 'Address', 'validator' => 'address'));
     $this->_validator->validate(array('field' => 'Address2', 'required' => false));
     $this->_validator->validate(array('field' => 'City'));
     $this->_validator->validate(array('field' => 'Country', 'validator' => 'selection', 'choices' => static::getFieldOptions('Country', 'values')));
     if (!$this->_validator->hasErrors('Country')) {
         $this->_validator->validate(array('field' => 'State_Province', 'validator' => 'state_province', 'country' => $this->Country));
         $this->_validator->validate(array('field' => 'Zip_Postal', 'validator' => 'zip_postal', 'country' => $this->Country));
         $this->_validator->validate(array('field' => 'Phone', 'validator' => 'phone', 'country' => $this->Country, 'required' => static::$requirePhone));
     }
     // save results
     $this->_isValid = $this->_isValid && !$this->_validator->hasErrors();
     if (!$this->_isValid) {
         $this->_validationErrors = array_merge($this->_validationErrors, $this->_validator->getErrors());
     }
     return $this->_isValid;
 }
Esempio n. 9
0
 public function validate($attributes = null, $clearErrors = true)
 {
     if ($this->EntranceTypeID == 1) {
         $this->scenario = "ZNO";
     }
     if ($this->EntranceTypeID == 2) {
         $this->scenario = "EXAM";
     }
     if ($this->EntranceTypeID == 3) {
         $this->scenario = "ZNOEXAM";
     }
     return parent::validate($attributes, $clearErrors);
 }
Esempio n. 10
0
 public function validate($deep = true)
 {
     // call parent
     parent::validate();
     $this->_validator->validate(array('field' => 'Title'));
     // check title uniqueness
     if ($this->isDirty && !$this->_validator->hasErrors('Title') && $this->Title) {
         $ExistingTag = Tag::getByTitle($this->Title);
         if ($ExistingTag && $ExistingTag->ID != $this->ID) {
             $this->_validator->addError('Title', 'A tag by this title already exists');
         }
         // Existing handle
         $ExistingHandle = Tag::getByHandle($this->Handle);
         if ($ExistingHandle && $ExistingHandle->ID != $this->ID) {
             $this->_validator->addError('Handle', 'A tag by this handle already exists');
         }
     }
     // save results
     return $this->finishValidation();
 }