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


PHP Validation::getMessages方法代碼示例

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


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

示例1: getMessages

 /**
  * Get error messages
  *
  * @return array
  */
 public function getMessages()
 {
     $messages = [];
     foreach ($this->validation->getMessages() as $messageObject) {
         $messages[$messageObject->getField()][$messageObject->getType()] = $messageObject->getMessage();
     }
     return $messages;
 }
開發者ID:kachit,項目名稱:phalcon-lib,代碼行數:13,代碼來源:AbstractValidation.php

示例2: signup

 public function signup($data)
 {
     foreach ($data as $k => $v) {
         $this->{$k} = $v;
     }
     $this->confirm = 1;
     $validation = new Validation();
     $validation->add('email', new Validation\Validator\Email(array('message' => 'Указан не действительный E-mail')));
     $validation->add('email', new \App\Library\Validators\Uniqueness(array("model" => 'App\\Models\\Users', "message" => "Такой E-mail уже используется.")));
     $validation->add('fname', new Validation\Validator\PresenceOf(array('message' => 'Поле "Имя" должно быть заполнено')));
     $validation->add('fname', new Validation\Validator\StringLength(array("max" => 40, 'messageMaximum' => 'Длина текста в поле "' . $this->getLabel('fname') . '" должна быть не более 40 символов')));
     $validation->add('lname', new Validation\Validator\StringLength(array("max" => 40, 'messageMaximum' => 'Длина текста в поле "' . $this->getLabel('lname') . '" должна быть не более 40 символов')));
     $validation->add('thname', new Validation\Validator\StringLength(array("max" => 40, 'messageMaximum' => 'Длина текста в поле "' . $this->getLabel('thname') . '" должна быть не более 40 символов')));
     $validation->add('password', new Validation\Validator\PresenceOf(array('message' => 'Пароль должен быть указан')));
     $validation->add('password', new Validation\Validator\Confirmation(array('with' => 'password_confirm', 'message' => '"Пароль" и "Повтор пароля" должны совпадать')));
     $messages = $validation->validate($data);
     if (count($messages)) {
         return $validation->getMessages();
     } else {
         if ($this->create() === true) {
             return true;
         } else {
             return $this->getMessages();
         }
     }
 }
開發者ID:atnartur,項目名稱:SimpleBannerRotator,代碼行數:26,代碼來源:Users.php

示例3: getMessages

 /**
  * @author Adeyemi Olaoye <yemi@cottacush.com>
  * @return mixed|string
  */
 public function getMessages()
 {
     $messages = [];
     foreach (parent::getMessages() as $message) {
         $messages[] = $message->getMessage();
     }
     return $this->getSentenceFromArray($messages);
 }
開發者ID:cottacush,項目名稱:phalcon-utils,代碼行數:12,代碼來源:BaseValidation.php

示例4: getMessages

 public function getMessages()
 {
     $messages = [];
     foreach (parent::getMessages() as $message) {
         $messages[] = $message->getMessage();
     }
     return $messages;
 }
開發者ID:caiofralmeida,項目名稱:soccer-company-event,代碼行數:8,代碼來源:Validation.php

示例5: testShouldValidateUsingDigitsInDecimalValidation

 public function testShouldValidateUsingDigitsInDecimalValidation()
 {
     $validation = new Validation();
     $validation->add('number1', new Decimal(['places' => 2, 'digits' => 2, 'label' => 'Magic number #1', 'message' => ':field must contain valid decimal value']));
     $validation->add('number2', new Decimal(['places' => 2, 'digits' => 1, 'label' => 'Magic number #2', 'message' => ':field must contain valid decimal value']));
     $validation->validate(['number1' => '9.99', 'number2' => '6.99']);
     $messages = $validation->getMessages();
     $this->assertEquals(1, $messages->count());
     $this->assertEquals('Magic number #1 must contain valid decimal value', $messages[0]->getMessage());
     $this->assertEquals('Decimal', $messages[0]->getType());
 }
開發者ID:phalcon,項目名稱:incubator,代碼行數:11,代碼來源:DecimalTest.php

示例6: login

 /**
  * login
  * @param array $data
  * @return bool
  * @throws Exception
  */
 public function login($data)
 {
     if (!is_array($data)) {
         throw new Exception('Login data mas by an array');
     }
     $validation = new Validation();
     $validation->add('email', new Email(['message' => 'Invalid email', 'required' => true]))->add('password', new StringLength(['max' => 255, 'min' => 4, 'message' => 'The password must be at least 4 characters', 'required' => true]));
     $validation->validate($data);
     $this->addMessages($validation->getMessages());
     if (!empty($this->getMessages())) {
         return false;
     }
     $this->setAttributes($data);
     return $this->user()->login($this->email, $this->password);
 }
開發者ID:remk-wadriga,項目名稱:phalcon-base-application-project,代碼行數:21,代碼來源:LoginForm.php

示例7: beforeValidation

 public function beforeValidation()
 {
     $validation = new Validation();
     $validation->add('password', new Confirmation(array('message' => 'Password doesn\'t match confirmation', 'with' => 'retype_password')));
     $validation->validate(['password' => $this->password, 'retype_password' => $this->retype_password]);
     $this->addMessages($validation->getMessages());
     if (!empty($this->getMessages())) {
         return false;
     }
     if ($this->reg_date === null) {
         $this->reg_date = $this->timeService()->currentDateTime();
     }
     if ($this->role === null) {
         $this->role = self::ROLE_USER;
     }
     if ($this->status === null) {
         $this->status = self::STATUS_NEW;
     }
     if ($this->rating === null) {
         $this->rating = (int) $this->rating;
     }
     if ($this->password !== null) {
         $this->password_hash = $this->createPasswordHash();
     }
     return parent::beforeValidation();
 }
開發者ID:remk-wadriga,項目名稱:itm-phalcon-project,代碼行數:26,代碼來源:User.php

示例8: validation

 private function validation(array $param)
 {
     $validation = new Validation();
     $validation->add('module', new PresenceOf(['message' => 'O nome da aplicação é necessária.']));
     $validation->add('module', new StringLength(['max' => 20, 'min' => 2, 'messageMaximum' => 'Nome da aplicação muito grande!', 'messageMinimum' => 'Nome da aplicação muito pequeno!']));
     $validation->add('todo', new PresenceOf(['message' => 'O nome da atividade é necessário.']));
     $validation->add('todo', new StringLength(['max' => 20, 'min' => 2, 'messageMaximum' => 'Nome da atividade muito grande!', 'messageMinimum' => 'Nome da atividade muito pequeno!']));
     $validation->add('action', new PresenceOf(['message' => 'O nome da ação é necessária.']));
     $validation->add('action', new StringLength(['max' => 20, 'min' => 2, 'messageMaximum' => 'Nome da ação muito grande!', 'messageMinimum' => 'Nome da ação muito pequeno!']));
     $validation->validate($param);
     if ($validation->getMessages()->count()) {
         foreach ($validation->getMessages() as $message) {
             throw new Phalcon\Mvc\Micro\Exception($message, 401);
         }
     }
 }
開發者ID:Jhorzyto,項目名稱:phalcon-rest-api-module,代碼行數:16,代碼來源:app.php

示例9: getMessages

 /**
  * @return array
  */
 public function getMessages()
 {
     $this->validation->getMessages()->filter($this->field);
 }
開發者ID:logikostech,項目名稱:auth,代碼行數:7,代碼來源:PasswordStrength.php

示例10: beforeSave

 public function beforeSave($data = null)
 {
     if (!$this->isNew()) {
         return true;
     }
     $validation = new Validation();
     $validation->add('password', new Confirmation(array('message' => 'Password doesn\'t match confirmation', 'with' => 'retype_password')));
     $validation->validate($data);
     $this->addMessages($validation->getMessages());
     if (!empty($this->getMessages())) {
         return false;
     }
     if (!isset($data['reg_date'])) {
         $data['reg_date'] = $this->timeService()->currentDateTime();
     }
     if (!isset($data['role'])) {
         $data['role'] = self::ROLE_USER;
     }
     if (!isset($data['status'])) {
         $data['status'] = self::STATUS_NEW;
     }
     if (!isset($data['rating'])) {
         $data['rating'] = (int) $this->rating;
     }
     if (isset($data['password'])) {
         $data['password_hash'] = $this->createPasswordHash($data['password'], $data['reg_date'], $data['email']);
     }
     return $data;
 }
開發者ID:remk-wadriga,項目名稱:phalcon-base-application-project,代碼行數:29,代碼來源:User.php


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