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


PHP GUMP::get_errors_array方法代码示例

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


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

示例1: validate

 public static function validate(\RedBeanPHP\OODBBean $bean)
 {
     $data = $bean->export();
     $model = $bean->box() !== null ? $bean->box() : null;
     if (!$model) {
         throw new ModelValidation_Exception('This bean does not have a model!');
     }
     $rules = isset($model::$rules) ? $model::$rules : null;
     if (!$rules) {
         throw new ModelValidation_Exception('This bean does not have any established rules!');
     }
     $validations = [];
     $filters = [];
     $labels = [];
     $messages = [];
     foreach ($rules as $field => $rule) {
         if (isset($rule['filter'])) {
             $filters[$field] = $rule['filter'];
         }
         if (isset($rule['label'])) {
             $labels[$field] = $rule['label'];
         }
         if (isset($rule['validation'])) {
             $validations[$field] = $rule['validation'];
         }
         if (isset($rule['message'])) {
             $field = isset($rule['label']) ? $rule['label'] : ucwords(str_replace(array('_', '-'), chr(32), $field));
             $messages[$field] = $rule['message'];
         }
     }
     $gump = new \GUMP();
     if (!empty($filters)) {
         $gump->filter_rules($filters);
     }
     if (!empty($validations)) {
         $gump->validation_rules($validations);
     }
     if (!empty($labels)) {
         $gump->set_field_names($labels);
     }
     $validated_data = $gump->run($data);
     if ($validated_data === false) {
         return self::default2custom_errors($gump->get_errors_array(), $messages);
     } else {
         $bean->import($validated_data);
         return true;
     }
 }
开发者ID:filisko,项目名称:redbean-validation-plugin,代码行数:48,代码来源:ModelValidation.php

示例2: GUMP

<?php

require "gump.class.php";
$validator = new GUMP();
$_POST = $validator->sanitize($_POST);
$rules = array('username' => 'required|alpha_numeric|max_len,100|min_len,6', 'password' => 'required|max_len,100|min_len,6', 'email' => 'required|valid_email', 'gender' => 'required|exact_len,1', 'credit_card' => 'required|valid_cc', 'bio' => 'required');
$validated = $validator->validate($_POST, $rules);
if ($validated === TRUE) {
    $result["result"] = true;
    die(json_encode($result));
} else {
    $result['error'] = $validator->get_errors_array();
    $result["result"] = false;
    die(json_encode($result));
}
开发者ID:indablackk,项目名称:GeekBrains_JavaScript,代码行数:15,代码来源:validator.php

示例3: register

 /**
  * Handle account registrations and view rendering
  */
 public function register()
 {
     // If the user is already logged in, redirect
     if (\Helpers\Session::get('loggedin')) {
         \Helpers\Url::redirect('Courses');
     }
     // If the registration form is submitted
     if (isset($_POST['submit'])) {
         // Check if the student exists
         $studentExists = $this->account->studentExists($_POST['student_id']);
         // If user does not exists
         if (!$studentExists) {
             $validator = new GUMP();
             // Sanitize the submission
             $_POST = $validator->sanitize($_POST);
             // Set the data
             $input_data = array('student_id' => $_POST['student_id'], 'student_name' => $_POST['student_name'], 'student_phone' => $_POST['student_phone'], 'student_password' => $_POST['student_password'], 'student_password_confirmation' => $_POST['student_password_confirmation']);
             // Define custom validation rules
             $rules = array('student_id' => 'required|numeric|min_len,5', 'student_name' => 'required|alpha_space', 'student_phone' => 'required|phone_number', 'student_password' => 'required|regex,/^\\S*(?=\\S{6,})(?=\\S*[a-z])(?=\\S*[A-Z])(?=\\S*[\\d])\\S*$/', 'student_password_confirmation' => 'required|contains,' . $_POST['student_password']);
             // Define validation filters
             $filters = array('student_id' => 'trim|sanitize_string', 'student_name' => 'trim|sanitize_string', 'student_phone' => 'trim|sanitize_string', 'student_password' => 'trim', 'student_password_confirmation' => 'trim');
             // Validate the data
             $_POST = $validator->filter($_POST, $filters);
             $validated = $validator->validate($_POST, $rules);
             // If data is valid
             if ($validated === true) {
                 // Create password hash
                 $password = $_POST['student_password'];
                 $hash = \Helpers\Password::make($password);
                 // Insert student into DB
                 $student_data = array('StudentId' => $_POST['student_id'], 'Name' => $_POST['student_name'], 'Phone' => $_POST['student_phone'], 'Password' => $hash);
                 // Insert the student into the database
                 $this->account->insertStudent($student_data);
                 // Get the newly created user hash
                 $currentUser = $this->account->getStudentHash($_POST['student_id']);
                 // Create a session with user info
                 \Helpers\Session::set('StudentId', $currentUser[0]->StudentId);
                 \Helpers\Session::set('Name', $currentUser[0]->Name);
                 \Helpers\Session::set('loggedin', true);
                 // Redirect to course selection page
                 \Helpers\Url::redirect('Courses');
             } else {
                 // Set errors
                 $error = $validator->get_errors_array();
             }
         } else {
             // Set additional error
             $error['exists'] = 'ID already exists';
         }
     }
     $data['title'] = 'New User';
     View::renderTemplate('header', $data, 'account');
     View::render('account/register', $data, $error);
     View::renderTemplate('footer', $data, 'account');
 }
开发者ID:egnsh93,项目名称:cst8257-Project,代码行数:58,代码来源:Account.php

示例4: GUMP

require_once 'src/EXPORT/Station.php';
require_once 'src/EXPORT/Pax6_tarif.php';
require_once 'src/EXPORT/Pax3_tarif.php';
require_once 'src/EXPORT/Pax10_tarif.php';
require_once 'src/EXPORT/Pax16_tarif.php';
require_once 'src/EXPORT/Pax40_tarif.php';
require_once 'process.php';
session_start();
$gump = new GUMP();
$_POST = $gump->sanitize($_POST);
// You don't have to sanitize, but it's safest to do so.
$gump->validation_rules(array('depart' => 'required|max_len,90|min_len,5', 'destination' => 'required|max_len,90|min_len,5', 'passager' => 'required|max_len,40|min_len,5', 'retour' => 'required|alpha_dash|max_len,20|min_len,4', 'clientName' => 'required|alpha_space|max_len,40|min_len,2', 'clientEmail' => 'required|valid_email', 'clientTel' => 'required|numeric|max_len,15|min_len,5', 'clientType' => 'required|max_len,90|min_len,4', 'clientPickUP' => 'required|date', 'clientPickTimeHUP' => 'required|numeric|max_len,2', 'clientPickTimeMUP' => 'required|numeric|max_len,2'));
$validated_data = $gump->run($_POST);
if ($validated_data === false) {
    $chaine = "Les données entrées sont erronés : <br>";
    foreach ($gump->get_errors_array() as $strings) {
        $chaine = $chaine . $strings . '<br>';
    }
    $_SESSION['aERROR'] = $chaine;
    Redirect('reservation.php', false);
} else {
    if ($_POST['retour'] == "Aller-Retour" && (!isset($_POST['clientPickBackUP']) || !isset($_POST['clientPickBackTimeHUP']) || !isset($_POST['clientPickBackTimeMUP']))) {
        $is_valid = GUMP::is_valid($_POST, array('clientPickBackUP' => 'required|date', 'clientPickBackTimeHUP' => 'required|numeric|max_len,2', 'clientPickBackTimeMUP' => 'required|numeric|max_len,2'));
        if (!($is_valid === true)) {
            $_SESSION['aERROR'] = "Vous avez choisi un Aller-Retour mais vous n'avez pas spécifié le champ <strong>Temps Retour</strong> ";
            Redirect('reservation.php', false);
        }
    }
    $consumer = new Consumer();
    $consumer->setName($_POST['clientName']);
    $consumer->setEmail($_POST['clientEmail']);
开发者ID:anouarattn,项目名称:projet_nabil,代码行数:31,代码来源:processReservation.php


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