class ValidationException extends Exception (View source)

Properties

Validator $validator

The validator instance.

Response|null $response

The recommended response to send to the client.

int $status

The status code to use for the response.

string $errorBag

The name of the error bag.

string $redirectTo

The path the client should be redirected to.

Methods

void
__construct(Validator $validator, Response|null $response = null, string $errorBag = 'default')

Create a new exception instance.

withMessages(array $messages)

Create a new validation exception from a plain array of messages.

static string
summarize(Validator $validator)

Create an error message summary from the validation errors.

array
errors()

Get all of the validation error messages.

$this
status(int $status)

Set the HTTP status code to be used for the response.

$this
errorBag(string $errorBag)

Set the error bag on the exception.

$this
redirectTo(string $url)

Set the URL to redirect to on a validation error.

Response|null
getResponse()

Get the underlying response instance.

Details

void __construct(Validator $validator, Response|null $response = null, string $errorBag = 'default')

Create a new exception instance.

Parameters

Validator $validator
Response|null $response
string $errorBag

Return Value

void

static ValidationException withMessages(array $messages)

Create a new validation exception from a plain array of messages.

Parameters

array $messages

Return Value

ValidationException

static protected string summarize(Validator $validator)

Create an error message summary from the validation errors.

Parameters

Validator $validator

Return Value

string

array errors()

Get all of the validation error messages.

Return Value

array

$this status(int $status)

Set the HTTP status code to be used for the response.

Parameters

int $status

Return Value

$this

$this errorBag(string $errorBag)

Set the error bag on the exception.

Parameters

string $errorBag

Return Value

$this

$this redirectTo(string $url)

Set the URL to redirect to on a validation error.

Parameters

string $url

Return Value

$this

Response|null getResponse()

Get the underlying response instance.

Return Value

Response|null