InputValidation
class InputValidation implements MiddlewareInterface
Input validation middleware.
Traits
Basic content negotiation.
Properties
protected int | $httpStatusCode | Default HTTP status code for invalid requests. | |
protected string | $errorsFlashKey | Session flash key for errors. | |
protected string | $oldInputFlashKey | Session flash key for old input. | |
protected string | $errorsVariableName | Errors view variable name. | |
protected string | $oldInputVariableName | Old input view variable name. | |
protected string | $defaultMessage | Default error message. | |
protected Request | $request | Request. | |
protected Response | $response | Response. | |
protected URLBuilder | $urlBuilder | URL builder. | |
protected Session|null | $session | Session. | |
protected ViewFactory|null | $viewFactory | View factory. |
Methods
bool
expectsType(array $mimeTypes, string|null $suffix = null)
Does the client expect the provided mime type?
bool
respondWithType(array $mimeTypes, string|null $suffix = null)
Should we respond with the provided mime type?
__construct(Request $request, Response $response, URLBuilder $urlBuilder, Session|null $session = null, ViewFactory|null $viewFactory = null)
Constructor.
bool
string
handleRedirect(Response $response, ValidationException $exception)
Add errors to flash data and redirect.
string
buildXmlFromException(ValidationException $exception, string $charset)
Builds XML based on the exception.
Details
in ContentNegotiationTrait at line 27
protected bool
expectsType(array $mimeTypes, string|null $suffix = null)
Does the client expect the provided mime type?
in ContentNegotiationTrait at line 44
protected bool
expectsJson()
Does the client expect JSON?
in ContentNegotiationTrait at line 54
protected bool
expectsXml()
Does the client expect XML?
in ContentNegotiationTrait at line 66
protected bool
respondWithType(array $mimeTypes, string|null $suffix = null)
Should we respond with the provided mime type?
in ContentNegotiationTrait at line 83
protected bool
respondWithJson()
Should we respond with JSON?
in ContentNegotiationTrait at line 93
protected bool
respondWithXml()
Should we respond with XML?
at line 122
__construct(Request $request, Response $response, URLBuilder $urlBuilder, Session|null $session = null, ViewFactory|null $viewFactory = null)
Constructor.
at line 142
protected bool
shouldRedirect(Request $request, ValidationException $exception)
Should we redirect the client?
at line 158
protected string
getRedirectUrl(ValidationException $exception)
Get the redirect URL.
at line 170
protected Response
handleRedirect(Response $response, ValidationException $exception)
Add errors to flash data and redirect.
at line 188
protected string
buildXmlFromException(ValidationException $exception, string $charset)
Builds XML based on the exception.
at line 211
protected Response
handleOutput(Response $response, ValidationException $exception)
Output errors.