本文整理汇总了PHP中Illuminate\Contracts\Validation\Validator::getMessageBag方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::getMessageBag方法的具体用法?PHP Validator::getMessageBag怎么用?PHP Validator::getMessageBag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Validation\Validator
的用法示例。
在下文中一共展示了Validator::getMessageBag方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getErrors
/**
* Get validation errors
*
* @return array
*/
public function getErrors()
{
if (!$this->validator || !$this->validator instanceof Validator) {
throw new \InvalidArgumentException(sprintf('Form %s was not validated. To validate it, call "isValid" method before retrieving the errors', get_class($this)));
}
return $this->validator->getMessageBag()->getMessages();
}
示例2: failedValidation
protected function failedValidation(Validator $validator)
{
if ($this->ajax()) {
$this->session()->flashInput($this->all());
$this->session()->flash('errors', $validator->getMessageBag());
}
parent::failedValidation($validator);
}
示例3: failedValidation
protected function failedValidation(Validator $validator)
{
$messages = $validator->errors();
if ($messages->has('email', '<p>:The email has already been taken.</p>')) {
$subscription = Subscription::where('email', $this->request->get('email'))->first();
if (!$subscription->confirmed) {
$this->mailer->sendEmailConfirmationFor($subscription);
} else {
$messages = ['email.unique:subscriptions' => 'That email address is already signed up'];
$validator->getMessageBag()->merge($messages);
$this->mailer->sendEmailRejectionFor($subscription);
}
}
throw new HttpResponseException($this->response($this->formatErrors($validator)));
}
示例4: formatErrors
/**
* Formats the validators errors to allow any number of security questions.
*
* @param Validator $validator
*
* @return array
*/
protected function formatErrors(Validator $validator)
{
$errors = $validator->getMessageBag()->toArray();
$processed = [];
foreach ($errors as $key => $error) {
$parts = explode('.', $key);
// If we have exactly two parts, we can work with the error message.
if (count($parts) === 2) {
list($name, $key) = $parts;
$field = sprintf('%s[%s]', $name, $key);
$processed[$field] = $error;
}
}
return $processed;
}
示例5: formatErrors
/**
* Format the errors from the given Validator instance.
*
* @param \Illuminate\Contracts\Validation\Validator $validator
* @return array
*/
protected function formatErrors(Validator $validator)
{
return $validator->getMessageBag()->toArray();
}
示例6: errorWrongArgsValidator
/**
* Generates a Response with a 400 HTTP header and a given message from validator
*
* @param Validator $validator
* @return ResponseFactory
*/
public function errorWrongArgsValidator(Validator $validator)
{
return $this->errorWrongArgs($validator->getMessageBag()->toArray());
}
示例7: addValidatorErrors
/**
* @param Validator $validator
*/
protected function addValidatorErrors(Validator $validator)
{
$messages = $validator->getMessageBag();
$this->addErrors($this->errorFactory->filterParametersMessages($messages));
}
示例8: pushValidation
/**
* Creates an alert from the result of validator.
*
* The type of the alert will be TYPE_VALIDATION
*
* @param Validator $validator
* @param null $title
* @param null $view
*/
public function pushValidation(Validator $validator, $title = null, $view = null)
{
$messages = $validator->getMessageBag()->all();
$this->push($messages, Alert::TYPE_VALIDATION, $title, $view);
}
示例9: getData
/**
* Get the error data.
*
* @return array|null
*/
public function getData()
{
return ['fields' => $this->validator->getMessageBag()->toArray()];
}
示例10: addValidatorErrors
/**
* @param Validator $validator
*/
protected function addValidatorErrors(Validator $validator)
{
$messages = $validator->getMessageBag();
$this->addErrors($this->errorFactory->resourceInvalidAttributesMessages($messages));
}
示例11: throwValidationException
/**
* Throw the failed validation exception.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Contracts\Validation\Validator $validator
* @return void
*
* @throws ResourceException
*/
protected function throwValidationException(Request $request, $validator)
{
throw new ResourceException($this->failedValidationMessage, $validator->getMessageBag());
}
示例12: formatValidationErrors
/**
* Format the validation errors to be returned.
*
* @param \Illuminate\Contracts\Validation\Validator $validator
* @return array
*/
protected function formatValidationErrors(\Illuminate\Contracts\Validation\Validator $validator)
{
zbase_alert(\Zbase\Zbase::ALERT_ERROR, $validator->getMessageBag(), ['formvalidation' => true]);
return $validator->errors()->getMessages();
}