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


PHP Validator::getErrors方法代碼示例

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


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

示例1: validateModification

 /**
  * Validate project modification
  *
  * @access public
  * @param  array   $values           Form values
  * @return array   $valid, $errors   [0] = Success or not, [1] = List of errors
  */
 public function validateModification(array $values)
 {
     if (!empty($values['identifier'])) {
         $values['identifier'] = strtoupper($values['identifier']);
     }
     $rules = array(new Validators\Required('id', t('This value is required')));
     $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
     return array($v->execute(), $v->getErrors());
 }
開發者ID:renothing,項目名稱:kanboard,代碼行數:16,代碼來源:ProjectValidator.php

示例2: validateModification

 /**
  * Validate modification
  *
  * @access public
  * @param  array   $values           Form values
  * @return array   $valid, $errors   [0] = Success or not, [1] = List of errors
  */
 public function validateModification(array $values)
 {
     $rules = array(new Validators\Required('id', t('Field required')));
     $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
     $result = $v->execute();
     $errors = $v->getErrors();
     if ($result && $this->tagModel->exists($values['project_id'], $values['name'], $values['id'])) {
         $result = false;
         $errors = array('name' => array(t('The name must be unique')));
     }
     return array($result, $errors);
 }
開發者ID:renothing,項目名稱:kanboard,代碼行數:19,代碼來源:TagValidator.php

示例3: validateLogin

 public function validateLogin(array $values)
 {
     $v = new Validator($values, array(new Validators\Required('username', t('The username is required')), new Validators\MaxLength('username', t('The maximum length is %d characters', 50), 50), new Validators\Required('password', t('The password is required'))));
     $result = $v->execute();
     $errors = $v->getErrors();
     if ($result) {
         $user = $this->getByUsername($values['username']);
         if ($user !== false && \password_verify($values['password'], $user['password'])) {
             $this->updateSession($user);
         } else {
             $result = false;
             $errors['login'] = t('Bad username or password');
         }
     }
     return array($result, $errors);
 }
開發者ID:ashwinrayaprolu1984,項目名稱:kanboard,代碼行數:16,代碼來源:user.php

示例4: grabErrors

 /**
  * Function that takes in a SimpleValidator object, grabs all the errors(if any), 
  * then throws the string of errors as a message.
  * 
  * @param \SimpleValidator\Validator $vdr
  * @return boolean
  * @throws \Exception
  */
 public function grabErrors($vdr)
 {
     //If errors were found, collect them into a string.
     if (!$vdr->execute()) {
         $str = "";
         //storing errors found.
         $array2D = $vdr->getErrors();
         //Grabbing errors from Validator object
         //Going through all arrays to find errors found
         foreach ($array2D as $array1D => $row) {
             foreach ($row as $error) {
                 $str .= $error . "<br />";
             }
         }
         //Throwing the message for the user to see.
         throw new \Exception($str);
     } else {
         return true;
     }
 }
開發者ID:justinbtadlock,項目名稱:lis4368_a3,代碼行數:28,代碼來源:Form.php

示例5: validate_login

function validate_login(array $values)
{
    $v = new Validator($values, array(new Validators\Required('username', t('The user name is required')), new Validators\MaxLength('username', t('The maximum length is 50 characters'), 50), new Validators\Required('password', t('The password is required'))));
    $result = $v->execute();
    $errors = $v->getErrors();
    if ($result) {
        $credentials = getCredentials();
        if ($credentials && $credentials['username'] === $values['username'] && password_verify($values['password'], $credentials['password'])) {
            $_SESSION['loggedin'] = true;
            $_SESSION['config'] = Config\get_all();
            // Setup the remember me feature
            if (!empty($values['remember_me'])) {
                $cookie = RememberMe\create(DatabaseModel\select(), $values['username'], Config\get_ip_address(), Config\get_user_agent());
                RememberMe\write_cookie($cookie['token'], $cookie['sequence'], $cookie['expiration']);
            }
        } else {
            $result = false;
            $errors['login'] = t('Bad username or password');
        }
    }
    return array($result, $errors);
}
開發者ID:mrjovanovic,項目名稱:miniflux,代碼行數:22,代碼來源:user.php

示例6: validateModification

 /**
  * Validate filter modification
  *
  * @access public
  * @param  array   $values           Form values
  * @return array   $valid, $errors   [0] = Success or not, [1] = List of errors
  */
 public function validateModification(array $values)
 {
     $rules = array(new Validators\Required('id', t('Field required')), new Validators\Integer('id', t('This value must be an integer')));
     $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
     return array($v->execute(), $v->getErrors());
 }
開發者ID:renothing,項目名稱:kanboard,代碼行數:13,代碼來源:CustomFilterValidator.php

示例7: validateFields

 /**
  * Validate fields
  *
  * @access protected
  * @param  array   $values           Form values
  * @return array   $valid, $errors   [0] = Success or not, [1] = List of errors
  */
 protected function validateFields(array $values)
 {
     $v = new Validator($values, array(new Validators\Required('captcha', t('This value is required')), new Validators\Required('username', t('The username is required')), new Validators\MaxLength('username', t('The maximum length is %d characters', 50), 50)));
     return array($v->execute(), $v->getErrors());
 }
開發者ID:peripatetic-sojourner,項目名稱:kanboard,代碼行數:12,代碼來源:PasswordResetValidator.php

示例8: validateLogin

 /**
  * Validate user login
  *
  * @access public
  * @param  array   $values           Form values
  * @return array   $valid, $errors   [0] = Success or not, [1] = List of errors
  */
 public function validateLogin(array $values)
 {
     $v = new Validator($values, array(new Validators\Required('username', t('The username is required')), new Validators\MaxLength('username', t('The maximum length is %d characters', 50), 50), new Validators\Required('password', t('The password is required'))));
     $result = $v->execute();
     $errors = $v->getErrors();
     if ($result) {
         list($authenticated, $method) = $this->authenticate($values['username'], $values['password']);
         if ($authenticated === true) {
             // Create the user session
             $user = $this->getByUsername($values['username']);
             $this->updateSession($user);
             // Update login history
             $lastLogin = new LastLogin($this->db, $this->event);
             $lastLogin->create($method, $user['id'], $this->getIpAddress(), $this->getUserAgent());
             // Setup the remember me feature
             if (!empty($values['remember_me'])) {
                 $rememberMe = new RememberMe($this->db, $this->event);
                 $credentials = $rememberMe->create($user['id'], $this->getIpAddress(), $this->getUserAgent());
                 $rememberMe->writeCookie($credentials['token'], $credentials['sequence'], $credentials['expiration']);
             }
         } else {
             $result = false;
             $errors['login'] = t('Bad username or password');
         }
     }
     return array($result, $errors);
 }
開發者ID:antonivargas,項目名稱:bkpsite,代碼行數:34,代碼來源:user.php

示例9: validatePasswordModification

 /**
  * Validate password modification
  *
  * @access public
  * @param  array   $values           Form values
  * @return array   $valid, $errors   [0] = Success or not, [1] = List of errors
  */
 public function validatePasswordModification(array $values)
 {
     $v = new Validator($values, array(new Validators\Required('id', t('The user id is required')), new Validators\Required('current_password', t('The current password is required')), new Validators\Required('password', t('The password is required')), new Validators\MinLength('password', t('The minimum length is %d characters', 6), 6), new Validators\Required('confirmation', t('The confirmation is required')), new Validators\Equals('password', 'confirmation', t('Passwords don\'t match'))));
     if ($v->execute()) {
         // Check password
         if ($this->authentication->authenticate($_SESSION['user']['username'], $values['current_password'])) {
             return array(true, array());
         } else {
             return array(false, array('current_password' => array(t('Wrong password'))));
         }
     }
     return array(false, $v->getErrors());
 }
開發者ID:Null-Kelvin,項目名稱:kanboard,代碼行數:20,代碼來源:User.php

示例10: validateModification

 /**
  * Validate modification
  *
  * @access public
  * @param  array   $values           Form values
  * @return array   $valid, $errors   [0] = Success or not, [1] = List of errors
  */
 public function validateModification(array $values)
 {
     $v = new Validator($values, array(new Validators\Required('id', t('Field required')), new Validators\Required('opposite_id', t('Field required')), new Validators\Required('label', t('Field required')), new Validators\Unique('label', t('This label must be unique'), $this->db->getConnection(), self::TABLE)));
     return array($v->execute(), $v->getErrors());
 }
開發者ID:rbertani,項目名稱:kanboard,代碼行數:12,代碼來源:Link.php

示例11: validateFormCredentials

 /**
  * Validate credentials syntax
  *
  * @access public
  * @param  array   $values           Form values
  * @return array   $valid, $errors   [0] = Success or not, [1] = List of errors
  */
 public function validateFormCredentials(array $values)
 {
     $v = new Validator($values, array(new Validators\Required('username', t('The username is required')), new Validators\MaxLength('username', t('The maximum length is %d characters', 50), 50), new Validators\Required('password', t('The password is required'))));
     return array($v->execute(), $v->getErrors());
 }
開發者ID:namaljayathunga,項目名稱:kanboard,代碼行數:12,代碼來源:Authentication.php

示例12: validateModification

 /**
  * Validate comment modification
  *
  * @access public
  * @param  array   $values           Required parameters to save an action
  * @return array   $valid, $errors   [0] = Success or not, [1] = List of errors
  */
 public function validateModification(array $values)
 {
     $v = new Validator($values, array(new Validators\Required('id', t('This value is required')), new Validators\Integer('id', t('This value must be an integer')), new Validators\Required('comment', t('Comment is required'))));
     return array($v->execute(), $v->getErrors());
 }
開發者ID:antonivargas,項目名稱:bkpsite,代碼行數:12,代碼來源:comment.php

示例13: validate

function validate(array $values)
{
    $v = new Validator($values, array(new Validators\Required('name', t('The database name is required')), new Validators\AlphaNumeric('name', t('The name must have only alpha-numeric characters')), new Validators\Required('username', t('The user name is required')), new Validators\MaxLength('username', t('The maximum length is 50 characters'), 50), new Validators\Required('password', t('The password is required')), new Validators\MinLength('password', t('The minimum length is 6 characters'), 6), new Validators\Required('confirmation', t('The confirmation is required')), new Validators\Equals('password', 'confirmation', t('Passwords don\'t match'))));
    return array($v->execute(), $v->getErrors());
}
開發者ID:webbrewmtl,項目名稱:miniflux,代碼行數:5,代碼來源:database.php

示例14: validate

 /**
  * Validate creation/modification
  *
  * @access public
  * @param  array   $values           Form values
  * @return array   $valid, $errors   [0] = Success or not, [1] = List of errors
  */
 public function validate(array $values)
 {
     $v = new Validator($values, array(new Validators\Required('task_id', t('The task id is required')), new Validators\Integer('task_id', t('The task id must be an integer')), new Validators\Required('title', t('The title is required')), new Validators\MaxLength('title', t('The maximum length is %d characters', 100), 100), new Validators\Integer('user_id', t('The user id must be an integer')), new Validators\Integer('status', t('The status must be an integer')), new Validators\Numeric('time_estimated', t('The time must be a numeric value')), new Validators\Numeric('time_spent', t('The time must be a numeric value'))));
     return array($v->execute(), $v->getErrors());
 }
開發者ID:Null-Kelvin,項目名稱:kanboard,代碼行數:12,代碼來源:SubTask.php

示例15: validateProjectModification

 /**
  * Validate allow everybody
  *
  * @access public
  * @param  array   $values           Form values
  * @return array   $valid, $errors   [0] = Success or not, [1] = List of errors
  */
 public function validateProjectModification(array $values)
 {
     $v = new Validator($values, array(new Validators\Required('id', t('The project id is required')), new Validators\Integer('id', t('This value must be an integer')), new Validators\Integer('is_everybody_allowed', t('This value must be an integer'))));
     return array($v->execute(), $v->getErrors());
 }
開發者ID:jasonmoofang,項目名稱:kanboard,代碼行數:12,代碼來源:ProjectPermission.php


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