src/PeskyCMF/Http/Middleware/ValidateData.php
public function handle(Request $request, Closure $next) {
        /** @var Route $route */
        $route = $request->route();
        $actionInfo = $route->getAction();
        if (!empty($actionInfo['validate'])) {
            $messages = [];
            if (!empty($actionInfo['validation_messages'])) {
                $messages = trans($actionInfo['validation_messages']);
                if (!is_array($messages)) {
                    $messages = [];
                }
            }
            $errors = $this->validateAndReturnErrors($request, $actionInfo['validate'], $messages);
            if (!empty($errors)) {
                return $this->makeValidationErrorsJsonResponse($errors);
            }
        }
        return $next($request);
    }
public function handle(Request $request, Closure $next) {
        /** @var Route $route */
        $route = $request->route();
        $actionInfo = $route->getAction();
        if (!empty($actionInfo['validate'])) {
            $messages = [];
            if (!empty($actionInfo['validation_messages'])) {
                $messages = trans($actionInfo['validation_messages']);
                if (!is_array($messages)) {
                    $messages = [];
                }
            }
            $errors = $this->validateAndReturnErrors($request, $actionInfo['validate'], $messages);
            if (!empty($errors)) {
                return $this->makeValidationErrorsJsonResponse($errors);
            }
        }
        return $next($request);
    }
Handle an incoming request.

@param  Request $request
@param  \Closure $next
@return mixed