コード例 #1
0
ファイル: InstallCommand.php プロジェクト: fluxbb/installer
 protected function displayErrors(MessageBag $errors)
 {
     foreach ($errors->all() as $error) {
         $this->error($error);
     }
     $this->info('Please try again');
 }
コード例 #2
0
 /**
  * @return string
  */
 public function getHtmlMessage()
 {
     if (!$this->htmlMessage) {
         $this->htmlMessage = sprintf("<ul class='validation-msgs'><li>%s</li></ul>", join('</li><li>', $this->bag->all()));
     }
     return $this->htmlMessage;
 }
コード例 #3
0
ファイル: SelfValidating.php プロジェクト: znck/plug
 /**
  * Validate model.
  *
  * @return bool
  */
 public function validate()
 {
     $this->validationDirty = true;
     if (false === $this->fireValidationEvent('validating')) {
         $this->errors = $this->errors ?? new MessageBag();
         $this->errors->add('::validating', 'Pre-validation event returned false.');
         return false;
     }
     $validator = $this->getValidationFactory()->make($this->getAttributes(), $this->getValidationRules(), $this->getValidationMessages(), $this->getValidationCustomAttributes());
     if ($fails = $validator->fails()) {
         $this->errors = $validator->getMessageBag();
     }
     if (false === $this->fireValidationEvent('validated')) {
         $this->errors = $this->errors ?? new MessageBag();
         $this->errors->add('::validated', 'Post-validation event returned false.');
         return false;
     }
     return !$fails;
 }
コード例 #4
0
 /**
  * Handle a failed validation attempt.
  *
  * @param MessageBag $errors
  * @return mixed
  */
 protected function failedNestedValidation(MessageBag $errors)
 {
     throw new HttpResponseException($this->response($errors->toArray()));
 }
コード例 #5
0
 /**
  * Get the string representation of the exception.
  *
  * @return string
  */
 public function __toString()
 {
     $lines = explode("\n", parent::__toString());
     return array_shift($lines) . " \nValidation errors:\n" . implode($this->errors->all(), "\n") . "\n" . implode($lines, "\n");
 }
コード例 #6
0
ファイル: MessageHandler.php プロジェクト: khakanali/OpenMAll
 private function getListFromSystemErrorArray(MessageBag $systemErrors = null)
 {
     $list = '';
     if ($systemErrors) {
         foreach ($systemErrors->all() as $key => $value) {
             $list .= '<li>' . $value . '</li>';
         }
     }
     return $list;
 }
コード例 #7
0
 /**
  * Create a new validation exception instance.
  * @param MessageBag $errors
  */
 public function __construct(MessageBag $errors)
 {
     $this->errors = $errors->toArray();
 }
コード例 #8
0
 /**
  * @return bool
  */
 public function isEmpty()
 {
     return $this->messages->isEmpty();
 }
コード例 #9
0
 /**
  * @param MessageBag $messageBag
  * @return mixed
  */
 public function errorWrongArgsValidator(MessageBag $messageBag)
 {
     return $this->errorResponse(['code' => Error::CODE_VALIDATION_FAILED, 'title' => 'Input validation failed', 'details' => $messageBag->toArray()], SymfonyResponse::HTTP_UNPROCESSABLE_ENTITY);
 }
コード例 #10
0
 /**
  * ValidationJsonApiResponse constructor.
  * @param MessageBag $errors
  */
 public function __construct(MessageBag $errors)
 {
     $this->prepare('errors', $this->normalizeErrors($errors->all()));
 }
コード例 #11
0
 /**
  * Create a new validation exception instance.
  * @param MessageBag $errors
  * @param string $message
  * @param \Exception $previous
  * @param array $headers
  * @param int $code
  */
 public function __construct(MessageBag $errors, $message = 'There was an issue with the validation of provided entity', \Exception $previous = null, array $headers = [], $code = 0)
 {
     $this->errors = $errors->toArray();
     parent::__construct(Response::HTTP_UNPROCESSABLE_ENTITY, $message, $previous, $headers, $code);
 }