當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。