当前位置: 首页>>代码示例>>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;未经允许,请勿转载。