ValidationException class base

Thrown when validation fails; rendered as a Laravel-compatible 422: {"message": "...", "errors": {"field": ["..."]}}.

Inheritance

Constructors

ValidationException(Map<String, List<String>> errors)
A 422 with the messages of each field in errors; the message is the first error, plus how many more, as Laravel writes it.
ValidationException.withMessages(Map<String, Object> messages)
Builds an exception from literal messages (withMessages).
factory

Properties

errors → Map<String, List<String>>
Errors keyed by attribute (items.0.id).
final
hashCode → int
The hash code for this object.
no setterinherited
headers → Map<String, String>
Extra headers to send with the rendered response.
finalinherited
message → String
Human readable description of the failure.
finalinherited
prettyJson → bool
Whether the default renderer writes the body pretty-printed, as Laravel's Handler::prepareJsonResponse does for every HTTP error (JSON_PRETTY_PRINT). AuthenticationException overrides it: Laravel answers that one with a plain response()->json.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
status → int
HTTP status code.
finalinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, Object?>
JSON payload rendered by the exception handler.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

summarize(Map<String, List<String>> errors, {int? laravelCompat}) → String
Laravel 9 to 13 summary: the first message plus (and N more errors). Laravel 8 (COMPAT_LARAVEL_VERSION=8) always answered The given data was invalid.