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


PHP Validate::error方法代码示例

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


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

示例1: _upload_image

 public function _upload_image(Validate $array, $input)
 {
     if ($array->errors()) {
         // Don't bother uploading
         return;
     }
     // Get the image from the array
     $image = $array[$input];
     if (!Upload::valid($image) or !Upload::not_empty($image)) {
         // No need to do anything right now
         return;
     }
     if (Upload::valid($image) and Upload::type($image, $this->types)) {
         $filename = strtolower(Text::random('alnum', 20)) . '.jpg';
         if ($file = Upload::save($image, NULL, $this->directory)) {
             Image::factory($file)->resize($this->width, $this->height, $this->resize)->save($this->directory . $filename);
             // Update the image filename
             $array[$input] = $filename;
             // Delete the temporary file
             unlink($file);
         } else {
             $array->error('image', 'failed');
         }
     } else {
         $array->error('image', 'valid');
     }
 }
开发者ID:bosoy83,项目名称:progtest,代码行数:27,代码来源:image.php

示例2: password_validate

 public function password_validate(Validate $array, $field)
 {
     if ($this->loaded() && !array_key_exists($field, $this->_changed)) {
         return TRUE;
     }
     if (!Validate::min_length($array[$field], 3)) {
         $array->error($field, 'min_length', array(5));
         return FALSE;
     }
     if (!Validate::max_length($array[$field], 50)) {
         $array->error($field, 'max_length', array(50));
         return FALSE;
     }
     return TRUE;
 }
开发者ID:ariol,项目名称:adminshop,代码行数:15,代码来源:User.php

示例3: shop_got_item

 public function shop_got_item(Validate $array, $field)
 {
     $amount = $array[$field];
     $cost = $this->item->price * $amount;
     // Check if shop got enought items
     if ($this->item->amount < $amount) {
         $array->error($field, 'not_enough');
         return false;
     }
     // Check if user can afford it
     if ($this->character->money < $cost) {
         $array->error($field, 'expensive');
         return false;
     }
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:15,代码来源:shop.php

示例4: existe

 /**
  * Verifica que la persona exista.
  *
  * Se utiliza para otorgar las constancias.
  *
  * @param Validate $array
  * @param <type> $campo
  */
 public function existe(Validate $array, $campo)
 {
     if (ORM::factory("persona")->where("cedula", "=", $array[$campo])->count_all() == 0) {
         $array->error($campo, "no_existe");
     }
     return $array;
 }
开发者ID:reneegonam,项目名称:CoCo,代码行数:15,代码来源:persona.php

示例5: check_username

 /**
  * Username callback to check if username is valid
  */
 public function check_username(Validate $array, $field)
 {
     $exists = (bool) DB::select(array('COUNT("*")', 'total_count'))->from('users')->where('username', '=', $array[$field])->execute()->get('total_count');
     if (!$exists) {
         $array->error($field, 'not_found', array($array[$field]));
     }
 }
开发者ID:vimofthevine,项目名称:kohana-admin,代码行数:10,代码来源:auth.php

示例6: slug_available

 /**
  * Does the reverse of unique_key_exists() by triggering error if username exists
  * Validation Rule
  *
  * @param    Validate  $array   validate object
  * @param    string    $field   field name
  * @param    array     $errors  current validation errors
  * @return   array
  */
 public function slug_available(Validate $array, $field)
 {
     //die($field);
     if ($this->unique_key_exists($field, $array[$field])) {
         $array->error($field, 'slug_available', array($array[$field]));
     }
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:16,代码来源:item.php

示例7: check_unique_email

 /**
  * Validation callback to check that this user has a unique email
  * 
  * @param Validate $array the validate object to use
  * @param string   $field the field name to check
  * 
  * @return null
  */
 public function check_unique_email(Validate $array, $field)
 {
     $user = new Model_Vendo_User($array[$field]);
     // Only error if this is a new or different object
     if ($user->id and $user->id != $this->id) {
         $array->error($field, 'not_unique');
     }
 }
开发者ID:vendo,项目名称:core,代码行数:16,代码来源:automodeler.php

示例8: has_category

 public function has_category(Validate $array, $field)
 {
     $photo = (bool) DB::select(array('COUNT("*")', 'records_found'))->from('photos')->where('user_id', '=', Auth::instance()->get_user()->id)->where('category_id', '=', $array[$field])->execute($this->_db)->get('records_found');
     if ($photo) {
         $array->error($field, 'category', array($array[$field]));
         return FALSE;
     }
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:8,代码来源:photo.php

示例9: _check_password_matches

 /**
  * Validate callback wrapper for checking password match
  * @param Validate $array
  * @param string   $field
  * @return void
  */
 public static function _check_password_matches(Validate $array, $field)
 {
     $auth = Auth::instance();
     if ($array['password'] !== $array[$field]) {
         // Re-use the error messge from the 'matches' rule in Validate
         $array->error($field, 'matches', array('param1' => 'password'));
     }
 }
开发者ID:jonlb,项目名称:JxCMS,代码行数:14,代码来源:user.php

示例10: censor

 /**
  * Check username for profanity.
  *
  * @param   Validate  Validate object
  * @param   string    field name
  * @return  void
  */
 public function censor(Validate $array, $field)
 {
     $censor = Censor::factory($array[$field]);
     if ($censor->is_offensive()) {
         $array->error($field, 'censor', array($array[$field]));
         return FALSE;
     }
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:15,代码来源:caption.php

示例11: _check_password_matches

 /**
  * Validate callback wrapper for checking password match
  * @param Validate $array
  * @param string   $field
  * @return void
  */
 public function _check_password_matches(Validate $array, $field)
 {
     $auth = Auth::instance();
     $salt = $auth->find_salt($array['password']);
     if ($array['password'] !== $auth->hash_password($array[$field], $salt)) {
         // Re-use the error message from the 'matches' rule in Validate
         $array->error($field, 'matches', array('param1' => 'password'));
     }
 }
开发者ID:azuya,项目名称:Wi3,代码行数:15,代码来源:user.php

示例12: _unique_email

 public function _unique_email(Validate $array, $field)
 {
     // check the database for existing records
     $email_exists = (bool) ORM::factory('user')->where('email', '=', $array[$field])->where('id', '!=', $this->id)->count_all();
     if ($email_exists) {
         // add error to validation object
         $array->error($field, 'email_exists', array($array[$field]));
     }
 }
开发者ID:battle-io,项目名称:web-php,代码行数:9,代码来源:user.php

示例13: do_unique_email

 /**
  * Check to see if the email address is unique
  * @param $array
  * @param $field
  * @param $errors
  * @return unknown_type
  */
 public function do_unique_email(Validate $array, $field)
 {
     if (isset($array['u_email'])) {
         if ($this->current_user->email_exists($array['u_email'])) {
             // Email is not unique, so they have already registered with that email
             $array->error($field, 'unique_email', array($array[$field]));
         }
     }
 }
开发者ID:ae0000,项目名称:ServerStats,代码行数:16,代码来源:user.php

示例14: username_available

 /**
  * Tests if a username exists in the database
  *
  * @param   Validation
  * @param   string      field to check
  * @return  array
  */
 public function username_available(Validate $array, $field)
 {
     if ($this->loaded() and !$this->changed($field)) {
         return TRUE;
     }
     // The value is unchanged
     if (Sprig::factory($this->_user_model, array($field => $array[$field]))->load(null, FALSE)->count()) {
         $array->error($field, 'username_available');
     }
 }
开发者ID:vimofthevine,项目名称:sentry,代码行数:17,代码来源:user.php

示例15: validate

 public function validate(Validate $array, $field)
 {
     if (empty($this->_file_errors)) {
         return TRUE;
     }
     foreach ($this->_file_errors as $error) {
         $array->error($field, $error);
     }
     return FALSE;
 }
开发者ID:ariol,项目名称:adminshop,代码行数:10,代码来源:Image.php


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