當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataObject::validate方法代碼示例

本文整理匯總了PHP中DataObject::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataObject::validate方法的具體用法?PHP DataObject::validate怎麽用?PHP DataObject::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DataObject的用法示例。


在下文中一共展示了DataObject::validate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validate

 protected function validate()
 {
     $this->beforeExtending('validate', function ($result) {
         $this->validSlug($result);
     });
     return parent::validate();
 }
開發者ID:milkyway-multimedia,項目名稱:ss-linkable-menus,代碼行數:7,代碼來源:LinkableMenu.php

示例2: validate

 /**
  * @return ValidationResult
  */
 protected function validate()
 {
     $valid = parent::validate();
     if (!$valid->valid()) {
         return $valid;
     }
     $type = trim($this->Type);
     if (empty($type)) {
         return $valid->error('Type is required!');
     }
     switch ($type) {
         case 'Persons':
             $this->Unit = 'units';
             break;
         case 'CO2':
             $this->Unit = 'ppm';
             break;
         case 'Temperature':
             $this->Unit = '°F';
             break;
         case 'Humidity':
             $this->Unit = '%';
             break;
     }
     $endpoint = trim($this->Endpoint);
     if (empty($endpoint)) {
         return $valid->error('Endpoint URL is required!');
     }
     if (filter_var($endpoint, FILTER_VALIDATE_URL) === FALSE) {
         return $valid->error('Endpoint URL is not a valid URL!');
     }
     return $valid;
 }
開發者ID:OpenStackweb,項目名稱:openstack-org,代碼行數:36,代碼來源:RoomMetricType.php

示例3: validate

 /**
  * @return ValidationResult
  *
  * TODO implement validation to ensure values aren't duplicated in multiple tiers
  */
 public function validate()
 {
     $result = parent::validate();
     /*$tierQuantity = ProductDiscountTier::get()
     			->filter(
     				array(
     					'ProductDiscountID' => $this->ProductDiscountID,
     					'Quantity' => $this->Quantity
     				)
     			)->first();
     
     		$tierPercentage = ProductDiscountTier::get()
     			->filter(
     				array(
     					'ProductDiscountID' => $this->ProductDiscountID,
     					'Percentage' => $this->Percentage
     				)
     			)->first();
     
     		if($tierQuantity->ID != 0 && $tierQuantity->ID != $this->ID){
     			$result->error($this->Quantity." is already used in another discount tier. Please use a different quantity");
     		}
     		if($tierPercentage->ID != 0 && $tierPercentage->ID != $this->ID){
     			$result->error($this->Percentage." is already used in another discount tier. Please use a different percentage");
     		}*/
     return $result;
 }
開發者ID:helpfulrobot,項目名稱:dynamic-foxystripe,代碼行數:32,代碼來源:ProductDiscountTier.php

示例4: validate

 protected function validate()
 {
     $result = parent::validate();
     if (!$this->getBuildTaskObject()) {
         $result->error("Please select a valid Build Task.");
     }
     return $result;
 }
開發者ID:tim-lar,項目名稱:silverstripe-queuedjobs,代碼行數:8,代碼來源:QueuedTask.php

示例5: validate

 public function validate()
 {
     $result = parent::validate();
     /*if($this->Country == 'DE' && $this->Postcode && strlen($this->Postcode) != 5) {
     			$result->error('Need five digits for German postcodes');
     		}*/
     return $result;
 }
開發者ID:helpfulrobot,項目名稱:dynamic-foxystripe,代碼行數:8,代碼來源:OrderDetail.php

示例6: validate

 public function validate()
 {
     $result = parent::validate();
     if ($this->ProductOptionGroupID == 0) {
         $result->error('Must set a Group prior to saving');
     }
     return $result;
 }
開發者ID:helpfulrobot,項目名稱:dynamic-foxystripe,代碼行數:8,代碼來源:OptionItem.php

示例7: validate

 public function validate()
 {
     $result = parent::validate();
     if (Catalogue::get()->filter(array('Video_title' => $this->Video_Title))->first()) {
         $result->error('This media has already been inserted to the catalogue.');
     }
     return $result;
 }
開發者ID:jareddreyer,項目名稱:catalogue,代碼行數:8,代碼來源:Form.php

示例8: validate

 public function validate()
 {
     $result = parent::validate();
     if (!$this->Title) {
         $result->error("Menu group must have a title.");
     }
     return $result;
 }
開發者ID:helpfulrobot,項目名稱:burnbright-silverstripe-shop-menu,代碼行數:8,代碼來源:Menu.php

示例9: validate

 public function validate()
 {
     $result = parent::validate();
     if (!$this->Value) {
         $result->error('Each select option must have a value.');
     }
     return $result;
 }
開發者ID:phill-m,項目名稱:silverstripe-metadata,代碼行數:8,代碼來源:MetadataSelectFieldOption.php

示例10: validate

 public function validate()
 {
     $result = parent::validate();
     if (intval($this->TargetFieldID) <= 0) {
         $result->error('you need to specify a target field!');
     }
     return $result;
 }
開發者ID:OpenStackweb,項目名稱:openstack-org,代碼行數:8,代碼來源:AbstractSurveyMigrationMapping.php

示例11: validate

 public function validate()
 {
     $validation = parent::validate();
     if (!$this->validTheme($this->Theme)) {
         $validation->error("Invalid Theme: " . $this->Theme);
     }
     return $validation;
 }
開發者ID:SpiritLevel,項目名稱:silverstripe-nivoslider,代碼行數:8,代碼來源:NivoSlider.php

示例12: validate

 public function validate()
 {
     $result = parent::validate();
     if (!$this->Name) {
         $result->error('"Name" can\'t be blank');
     }
     return $result;
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-frameworktest,代碼行數:8,代碼來源:Employee.php

示例13: validate

 public function validate()
 {
     $valid = parent::validate();
     if (trim($this->Title) == '') {
         $valid->error('Please give your article a title');
     }
     return $valid;
 }
開發者ID:axllent,項目名稱:silverstripe-news,代碼行數:8,代碼來源:NewsArticle.php

示例14: validate

 public function validate()
 {
     $result = parent::validate();
     if ($this->Type == 'Limited' && !$this->Quantity) {
         $result->error('You must enter a quantity for limited resources.');
     }
     return $result;
 }
開發者ID:textagroup,項目名稱:silverstripe-eventresources,代碼行數:8,代碼來源:EventResource.php

示例15: validate

 function validate()
 {
     if (!$this->Title) {
         return new ValidationResult(false, 'Title is required');
     } else {
         return parent::validate();
     }
 }
開發者ID:normann,項目名稱:silverstripe-frameworktest,代碼行數:8,代碼來源:Company.php


注:本文中的DataObject::validate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。