当前位置: 首页>>代码示例>>PHP>>正文


PHP ActiveRecord::validate方法代码示例

本文整理汇总了PHP中ActiveRecord::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::validate方法的具体用法?PHP ActiveRecord::validate怎么用?PHP ActiveRecord::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActiveRecord的用法示例。


在下文中一共展示了ActiveRecord::validate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * 
  * @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]);
     }
 }
开发者ID:filamentv,项目名称:yii2-app,代码行数:15,代码来源:ListModelFilter.php

示例2: validate

 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();
 }
开发者ID:jmealo,项目名称:Gatekeeper,代码行数:8,代码来源:Ban.php

示例3: validate

 public function validate()
 {
     // call parent
     parent::validate();
     $this->_validator->validate(array('field' => 'Email', 'validator' => 'email'));
     // save results
     return $this->finishValidation();
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:8,代码来源:EmailSubscriber.class.php

示例4: validate

 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;
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:14,代码来源:CategoryItem.class.php

示例5: validate

 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();
 }
开发者ID:aharley40,项目名称:slate-cbl,代码行数:14,代码来源:ContentArea.php

示例6: validate

 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();
 }
开发者ID:Sun-Wukong,项目名称:laddr,代码行数:16,代码来源:ProjectBuzz.php

示例7: validate

 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();
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:19,代码来源:GlobalHandle.class.php

示例8: validate

 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;
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:21,代码来源:Address.class.php

示例9: validate

 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);
 }
开发者ID:upmunspel,项目名称:abiturient,代码行数:13,代码来源:Personspeciality.php

示例10: validate

 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();
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:20,代码来源:Tag.class.php


注:本文中的ActiveRecord::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。