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


PHP Validation::add_error方法代码示例

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


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

示例1: _validate_icc_path

 public function _validate_icc_path(Validation $post, $field)
 {
     if (!empty($post->{$field})) {
         if (!@is_file($post->{$field})) {
             $post->add_error($field, t("No ICC profile exists at the location <code>%icc_path</code>", array("icc_path" => $post->{$field})));
         }
         $dcraw = rawphoto_graphics::detect_dcraw();
         if (version_compare($dcraw->version, "8.00", "<")) {
             $post->add_error($field, t("Versions of <em>dcraw</em> before <code>8.00</code> do not support an ICC profile"));
         }
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:12,代码来源:admin_rawphoto.php

示例2: layer_url_file_check

 /**
  * Performs validation checks on the layer url and layer file - Checks that at least
  * one of them has been specified using the applicable validation rules
  *
  * @param Validation $array Validation object containing the field names to be checked
  */
 public function layer_url_file_check(Validation $array)
 {
     // Ensure at least a layer URL or layer file has been specified
     if (empty($array->layer_url) and empty($array->layer_file) and empty($array->layer_file_old)) {
         $array->add_error('layer_url', 'atleast');
     }
     // Add validation rule for the layer URL if specified
     if (!empty($array->layer_url) and (empty($array->layer_file) or empty($array->layer_file_old))) {
         $array->add_rules('layer_url', 'url');
     }
     // Check if both the layer URL and the layer file have been specified
     if (!empty($array->layer_url) and (!empty($array->layer_file_old) or !empty($array->layer_file))) {
         $array->add_error('layer_url', 'both');
     }
 }
开发者ID:kjgarza,项目名称:thrasos,代码行数:21,代码来源:layer.php

示例3: valid_name

 /**
  * Validate the item name.  It can't conflict with other names, can't contain slashes or
  * trailing periods.
  */
 public function valid_name(Validation $v, $field)
 {
     $postage_band = ORM::factory("postage_band")->where("name", "=", $this->name)->find();
     if ($postage_band->loaded() && $postage_band->id != $this->id) {
         $v->add_error("name", "in_use");
     }
 }
开发者ID:Weerwolf,项目名称:gallery3-contrib,代码行数:11,代码来源:postage_band.php

示例4: action_edit_field

 public function action_edit_field()
 {
     $field_id = $this->request->param('options');
     xml::to_XML(array('field' => array('@id' => $field_id, '$content' => User::get_data_field_name($field_id))), $this->xml_content);
     if (count($_POST) && isset($_POST['field_name'])) {
         $post = new Validation($_POST);
         $post->filter('trim');
         $post->rule('Valid::not_empty', 'field_name');
         if ($post->validate()) {
             $post_values = $post->as_array();
             if ($post_values['field_name'] != User::get_data_field_name($field_id) && !User::field_name_available($post_values['field_name'])) {
                 $post->add_error('field_name', 'User::field_name_available');
             }
         }
         // Retry
         if ($post->validate()) {
             $post_values = $post->as_array();
             User::update_field($field_id, $post_values['field_name']);
             $this->add_message('Field ' . $post_values['field_name'] . ' updated');
             $this->set_formdata(array('field_name' => $post_values['field_name']));
         } else {
             $this->add_error('Fix errors and try again');
             $this->add_form_errors($post->errors());
             $this->set_formdata(array_intersect_key($post->as_array(), $_POST));
         }
     } else {
         $this->set_formdata(array('field_name' => User::get_data_field_name($field_id)));
     }
 }
开发者ID:rockymontana,项目名称:kohana-module-pajas,代码行数:29,代码来源:fields.php

示例5: file_check

 /**
  * Performs validation checks on the geometry file - Checks that at least
  * one of them has been specified using the applicable validation rules
  *
  * @param Validation $array Validation object containing the field names to be checked
  */
 public function file_check(Validation $array)
 {
     // Ensure at least a geometry URL or geometry file has been specified
     if (empty($array->kml_file) and empty($array->kml_file_old)) {
         $array->add_error('geometry_url', 'atleast');
     }
 }
开发者ID:rjmackay,项目名称:densitymap,代码行数:13,代码来源:densitymap_geometry.php

示例6: valid_name

 /**
  * Validate the item name.  It can't conflict with other names, can't contain slashes or
  * trailing periods.
  */
 public function valid_name(Validation $v, $field)
 {
     Kohana_Log::add("error", print_r("valid_name!", 1));
     $product = ORM::factory("product")->where("name", "=", $this->name)->find();
     if ($product->loaded() && $product->id != $this->id) {
         $v->add_error("name", "in_use");
     }
 }
开发者ID:ady1503,项目名称:gallery3-contrib,代码行数:12,代码来源:product.php

示例7: __dependents

 /**
  * If we want to delete the record, we need to check that no dependents exist.
  */
 public function __dependents(Validation $array, $field)
 {
     if ($array['deleted'] == 'true') {
         $record = ORM::factory('termlists_term', $array['id']);
         if (count($record->children) != 0) {
             $array->add_error($field, 'has_children');
         }
     }
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:12,代码来源:termlists_term.php

示例8: _unique_email

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

示例9: _dependents

 /**
  * If we want to delete the record, we need to check that no dependents exist.
  */
 public function _dependents(Validation $array, $field)
 {
     if ($array['deleted'] == 'true') {
         $record = ORM::factory('termlist', $array['id']);
         if ($record->terms->count() != 0) {
             $array->add_error($field, 'has_taxa');
         }
     }
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:12,代码来源:taxon_list.php

示例10: _url_is_free

 /**
  * Look if email and password match with db
  * @param Validation Validation object
  * @param string field that all goes on
  * @return boolean
  */
 public function _url_is_free(Validation $array, $field)
 {
     // Questing database if url string
     $url_is_free = $this->db->from(self::TN_PAGES)->where('url', $array[$field])->count_records();
     if ($url_is_free != 0) {
         $array->add_error($field, 'is_set');
     } else {
         return TRUE;
     }
 }
开发者ID:repli2dev,项目名称:re-eshop,代码行数:16,代码来源:page.php

示例11: _exists

 /**
  * Callback - check if payment exists in db
  * @return void
  * @param integer id of payment method 
  */
 public function _exists(Validation $post)
 {
     // If add->rules validation found any errors, get me out of here!
     if (array_key_exists('payment', $post->errors())) {
         return;
     }
     // Check if shipping method exists
     $data = $this->db->select('id')->from(self::TN_PAYMENT)->where('id', $post['payment'])->get();
     if (count($data) <= 0) {
         // Add a validation error, this will cause $post->validate() to return FALSE
         $post->add_error('payment', 'required');
     }
 }
开发者ID:repli2dev,项目名称:re-eshop,代码行数:18,代码来源:payment.php

示例12: _admin_check_address

 public function _admin_check_address(Validation $array, $input)
 {
     if ($array[$input] == '') {
         return;
     }
     // Fetch the lat and lon via Gmap
     list($lat, $lon) = Gmap::address_to_ll($array[$input]);
     if ($lat === NULL or $lon === NULL) {
         // Add an error
         $array->add_error($input, 'address');
     } else {
         // Set the latitude and longitude
         $_POST['lat'] = $lat;
         $_POST['lon'] = $lon;
     }
 }
开发者ID:HIVE-Creative,项目名称:spicers,代码行数:16,代码来源:gmaps_demo.php

示例13: status_update

 /**
  * @method status_update
  * @abstract Post status update to Twitter
  * @author Josh Turmel
  * @
  * @return array
  */
 public static function status_update($config)
 {
     $username = isset($config['username']) ? $config['username'] : '';
     $password = isset($config['password']) ? $config['password'] : '';
     $status = isset($config['status']) ? $config['status'] : '';
     $v = new Validation(array('username' => $username, 'password' => $password, 'status' => $status));
     // TODO: Add in the real requirements by Twitter, for now just required
     $v->add_rules('username', 'required');
     $v->add_rules('password', 'required');
     $v->add_rules('status', 'required');
     if ($v->validate() === false) {
         return array('success' => false, 'errors' => $v->errors('twitter'));
     }
     $appended_message = Kohana::config('twitter.appended_message');
     $max_length = self::status_length();
     if (strlen($status) > $max_length) {
         $status = substr($status, 0, $max_length - 2) . '...';
     }
     // Now add appended_message
     $status = $status . $appended_message;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, 'http://twitter.com/statuses/update.json');
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, 'status=' . $status);
     curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
     $output = curl_exec($ch);
     curl_close($ch);
     // Check for success or failure
     if (empty($output)) {
         $v = new Validation(array('twitter_response' => ''));
         $v->add_error('twitter_response', 'connection_failed');
         return array('success' => false, 'errors' => $v->errors('twitter'));
     } else {
         $output = json_decode($output);
         if (isset($output->error) && $output->error == 'Could not authenticate you.') {
             $v = new Validation(array('twitter_response' => ''));
             $v->add_error('twitter_response', 'authentication_failed');
             return array('success' => false, 'errors' => $v->errors('twitter'));
         } else {
             $output->success = true;
             return $output;
         }
     }
 }
开发者ID:uxturtle,项目名称:core-module,代码行数:53,代码来源:twitter.php

示例14: email_exists_chk

 /**
  * Checks if email address is associated with an account.
  * @param Validation $post $_POST variable with validation rules
  */
 public function email_exists_chk(Validation $post)
 {
     $users = ORM::factory('user');
     if (array_key_exists('resetemail', $post->errors())) {
         return;
     }
     if (!$users->email_exists($post->resetemail)) {
         $post->add_error('resetemail', 'invalid');
     }
 }
开发者ID:kjgarza,项目名称:thrasos,代码行数:14,代码来源:login.php

示例15: prevent_superadmin_modification

 /**
  * Ensures that only a superadmin can modify superadmin users, or upgrade a user to superadmin
  * @note this assumes the currently logged-in user isn't a superadmin
  */
 public static function prevent_superadmin_modification(Validation $post, $field)
 {
     if ($post[$field] == 'superadmin') {
         $post->add_error($field, 'superadmin_modify');
     }
 }
开发者ID:neumicro,项目名称:Ushahidi_Web_Dev,代码行数:10,代码来源:user.php


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