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


PHP Validator::getErrors方法代码示例

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


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

示例1: assertNotValid

 function assertNotValid($data, $errors)
 {
     $validator = new Validator();
     $validator->check($data, $this->schema);
     $this->assertEquals($errors, $validator->getErrors(), print_r($validator->getErrors(), true));
     $this->assertFalse($validator->isValid());
 }
开发者ID:hypercharge,项目名称:json-schema-php,代码行数:7,代码来源:ValidatorTest.php

示例2: actionLogin

 protected function actionLogin()
 {
     if ($this->_auth->getAuthStatus()) {
         header("Location: /");
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $validator = new Validator();
         $validator->setData($_POST);
         if ($validator->checkFieldsForEmpty(['email', 'password'])->validationResult()) {
             $email = $validator->getData('email');
             $password = md5(Config::SECRET . $validator->getData('password'));
             $login_result = $this->_link->select('users', ['id', 'login', 'role'])->selectWHERE_AND(['email' => $email, 'password' => $password])->sendSelectQuery();
             if ($login_result->num_rows != 0) {
                 $user = $login_result->fetch_assoc();
                 $_SESSION['user_id'] = $user['id'];
                 $_SESSION['role'] = $user['role'];
                 header("Location: " . $_SERVER['HTTP_REFERER']);
             } else {
                 $this->_error->loginError('auth falied');
             }
         } else {
             $this->_error->formError($validator->getErrors());
         }
     }
     $this->render('login');
 }
开发者ID:alexposseda,项目名称:events,代码行数:26,代码来源:controller.class.php

示例3: validateUniqueEmailFailed

 public function validateUniqueEmailFailed(array $data)
 {
     $v = new Validator($data, array(new Unique("email", "field must be unique", "customer")));
     if (!$v->execute()) {
         print_r($v->getErrors());
     } else {
         return true;
     }
 }
开发者ID:runningjack,项目名称:busticketNew,代码行数:9,代码来源:Driver.php

示例4: validate

 /**
  * Validate form arguments
  *
  * @param $args
  * @param $defaults
  * @return array
  * @throws \Exception
  */
 protected static function validate($args)
 {
     $validation = new Validator(static::$rules, $args, static::$defaults);
     if ($validation->fails()) {
         $errors = $validation->getErrors();
         $err_msg = self::validationErrorMsg($errors);
         throw new \Exception($err_msg);
     }
     return $validation->getArgs();
 }
开发者ID:dsopiarz,项目名称:wp-advanced-search,代码行数:18,代码来源:StdObject.php

示例5: validate

 /**
  * 验证数据
  */
 public function validate($data)
 {
     $fields = self::getFields();
     $validator = new Validator($fields, $data);
     $this->data = $validator->validate();
     if (!$this->data) {
         $this->errors = $validator->getErrors();
         return false;
     }
     return true;
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:14,代码来源:ModelForm.php

示例6: getAttributes

 /**
  * @return array
  */
 public function getAttributes()
 {
     $attrs = array('id' => $this->FormName(), 'action' => $this->FormAction(), 'method' => $this->FormMethod(), 'enctype' => $this->getEncType(), 'target' => $this->target, 'class' => $this->extraClass());
     if ($this->validator && $this->validator->getErrors()) {
         if (!isset($attrs['class'])) {
             $attrs['class'] = '';
         }
         $attrs['class'] .= ' validationerror';
     }
     $attrs = array_merge($attrs, $this->attributes);
     return $attrs;
 }
开发者ID:rasstislav,项目名称:silverstripe-framework,代码行数:15,代码来源:Form.php

示例7: getErrorsToDisplay

 /**
  * Returns the ValidationError objects for the errors and warnings that should be displayed.
  *
  * @since 0.4
  *
  * @return array of array of ValidationError
  */
 protected function getErrorsToDisplay()
 {
     $errors = array();
     $warnings = array();
     foreach ($this->validator->getErrors() as $error) {
         // Check if the severity of the error is high enough to display it.
         if ($error->shouldShow()) {
             $errors[] = $error;
         } elseif ($error->shouldWarn()) {
             $warnings[] = $error;
         }
     }
     return array('errors' => $errors, 'warnings' => $warnings);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:21,代码来源:ParserHook.php

示例8: img_profil

 public function img_profil($db, $user_id, $image, $path)
 {
     $validator = new Validator($_POST);
     $validator->isSize($image, 'Votre photo est trop lourde.');
     $validator->isExtension($image, 'Vous ne pouvez mettre que des fichiers avec les extensions suivantes : png, gif, jpg, jpeg.');
     $uploadfile = basename($_FILES[$image]['name']);
     $uploadfile = strtr($uploadfile, 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
     $img = $path . $uploadfile;
     if ($validator->isValid()) {
         $this->field_img($db, $user_id, $img, $image);
         move_uploaded_file($_FILES[$image]['tmp_name'], $img);
         $info_user = $this->checkId($db, $user_id);
         return $info_user->image = $img;
     } else {
         return $errors = $validator->getErrors();
     }
 }
开发者ID:Harmeko,项目名称:tweet_academie,代码行数:17,代码来源:Auth.php

示例9: validateFor

 /**
  * You can perform a single validation by using this method.
  * Result of validate() method (boolean) will be returned.
  *
  * @param $name string - Name of validator
  * @param $value mixed - Value to validate. If array,
  * all keys are taken as attributes and values as values.
  * @param $params array - Params for a validator
  * @return object
  * @throws \Exception
  */
 public static function validateFor($name, $value, array $params = [])
 {
     if (!is_string($name)) {
         throw new \UnexpectedValueException("Validator name must be a string, " . gettype($name) . " given");
     }
     $rules = [];
     # By default, empty value should be not valid
     $params = array_merge(['allowEmpty' => false], $params);
     if (is_array($value)) {
         $rules[] = array_merge([array_keys($value), $name], $params);
     } else {
         $rules[] = array_merge([$name, $name], $params);
         $value = [$name => $value];
     }
     $v = new Validator();
     $result = new \stdClass();
     $result->isValid = $v->setRules($rules)->loadData($value)->validate();
     $result->lastError = $v->getLastError();
     $result->errors = $v->getErrors();
     unset($v);
     return $result;
 }
开发者ID:xphoenyx,项目名称:valify,代码行数:33,代码来源:Validator.php

示例10: validate

 /**
  * Validates the layer.
  * 
  * @since 0.7.1
  */
 protected function validate()
 {
     $validator = new Validator();
     $validator->setParameters($this->properties, $this->getParameterDefinitions(array()));
     $validator->validateParameters();
     if ($validator->hasFatalError() !== false) {
         $this->errors = $validator->getErrors();
     }
     $this->properties = $validator->getParameterValues();
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:15,代码来源:Maps_Layer.php

示例11: Tweet

<?php

require_once '../autoload.php';
require_once '../include/results.php';
//rajouter order bye et condition si reply ou origine et recuper donner(function dans class)
$tweet = new Tweet($user_id);
// $tweet->getIdTweet();
/*var_dump($p = new Tweet($user_id, 2));
var_dump($p->getIdTweet());*/
// var_dump($p = new Tweet($user_id));
// var_dump($p->Tweet_follower($user_id));
if (isset($_FILES['file-input']) && !empty($_FILES['file-input']['name'])) {
    $uploaddir = '../view/img-user/tweet/';
    $validator = new Validator($_POST);
    $validator->isSize('file-input', 'You picture is too oversized');
    $validator->isExtension('file-input', 'You must upload a type of picture with png, gif, jpg, jpeg, please.');
    $uploadfile = basename($_FILES['file-input']['name']);
    $uploadfile = strtr($uploadfile, 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
    $img_tweet = $uploaddir . $uploadfile;
    if ($validator->isValid()) {
        move_uploaded_file($_FILES['file-input']['tmp_name'], $img_tweet);
        $tweet->newTweet($img_tweet);
        /*$info_user->avatar = $avatar;*/
    } else {
        $errors = $validator->getErrors();
    }
} else {
    $tweet->newTweet();
}
require_once '../view/accueil.php';
开发者ID:Harmeko,项目名称:tweet_academie,代码行数:30,代码来源:accueil.php

示例12: testMixedTypes

 public function testMixedTypes()
 {
     $tests = array(array("expect" => "array|bool|numeric|string", "got" => array("one"), "valid" => true), array("expect" => "array|bool|numeric|string", "got" => false, "valid" => true), array("expect" => "array|bool|numeric|string", "got" => 123, "valid" => true), array("expect" => "array|bool|numeric|string", "got" => "mystring", "valid" => true), array("expect" => "array|numeric", "got" => array("one"), "valid" => true), array("expect" => "array|numeric", "got" => 123, "valid" => true), array("expect" => "array|numeric", "got" => "mystring", "valid" => false), array("expect" => "array<string>|array<bool>", "got" => 123, "valid" => false), array("expect" => "array<string>|array<bool>", "got" => array("one", "two"), "valid" => true), array("expect" => "array<string>|array<bool>", "got" => array(true, true, false), "valid" => true), array("expect" => "array<string>|array<bool>", "got" => array(4.5, 7.8, 91.2), "valid" => false));
     foreach ($tests as $test) {
         $validation = new Validator(array('arg' => $test['expect']), array('arg' => $test['got']));
         $got = is_array($test['got']) ? implode(",", $test['got']) : $test['got'];
         $msg = sprintf("Testing %s with value=[%s], valid=%b.  Error: %s", $test['expect'], $got, $test['valid'], implode(" ", $validation->getErrors()));
         $this->assertEquals($test['valid'], $validation->passes(), $msg);
     }
 }
开发者ID:dsopiarz,项目名称:wp-advanced-search,代码行数:10,代码来源:TestValidator.php

示例13: array

<?php

// Require app files
require 'app/User.php';
require 'app/Validator.php';
require 'app/Helper.php';
// Set data and validation rules
$rules = array('email' => 'required|email', 'password' => 'required|min:8');
$data = array('email' => 'joost@tutsplus.com', 'password' => '12346789');
// Run validation
$validator = new Validator();
if ($validator->validate($data, $rules) == true) {
    // Validation passed. Set user values.
    $joost = new User();
    // method chaining is used
    $joost->setEmail($data['email'])->setPassword(getHash($data['password']));
    // Dump user
    var_dump($joost);
} else {
    // Validation failed. Dump validation errors.
    var_dump($validator->getErrors());
}
开发者ID:sheryarshirazi,项目名称:php-oop-fundamentals,代码行数:22,代码来源:index.php

示例14: json_encode

<?php

if (!isset($_POST['name'])) {
    die;
}
require __DIR__ . '/Validator.php';
require __DIR__ . '/Mailer.php';
$validator = new Validator();
if (!$validator->validate()) {
    echo json_encode(array('success' => 'false', 'errors' => $validator->getErrors()));
    die;
}
$mail = new Mailer();
$mail->addAddress("info@happysmugglers.com");
$msg = "\nHallo,<br /><br />\n\nHet contactformulier op uw website is ingevuld. Hieronder staan de ingevoerde gegevens:<br /><br />\n\n<table>";
if (isset($_POST['message'])) {
    $_POST['message'] = nl2br($_POST['message']);
}
foreach ($_POST as $key => $value) {
    if (is_array($value)) {
        $value = implode(", ", $value);
    }
    $msg .= "<tr>\n    <td>" . $key . "</td>\n    <td>" . $value . "</td>\n</tr>";
}
$msg .= "</table><br />";
$mail->setHTMLBody($msg);
if ($mail->send()) {
    echo json_encode(array('success' => true));
    exit;
}
echo json_encode(array('success' => false));
开发者ID:rapideinternet,项目名称:happysmuggler,代码行数:31,代码来源:handlecontact.php

示例15: validate

 /**
  * Validates the layer.
  * 
  * @since 0.7.1
  */
 protected function validate()
 {
     if ($this->hasValidated) {
         return;
     }
     $this->hasValidated = true;
     $validator = new Validator();
     $validator->setParameters($this->properties, $this->getParameterDefinitions());
     $validator->validateParameters();
     if ($validator->hasErrors() !== false) {
         $this->errors = $validator->getErrors();
     }
     $params = $validator->getParameterValues();
     $this->properties = $params;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:20,代码来源:Maps_Layer.php


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