src/Error/ExceptionRenderer.php
public function validation($error)
    {
        $url = $this->controller->request->getRequestTarget();
        $status = $code = $error->getCode();
        try {
            $this->controller->response = $this->controller->response->withStatus($status);
        } catch (Exception $e) {
            $status = 422;
            $this->controller->response = $this->controller->response->withStatus($status);
        }

        $sets = [
            'code' => $code,
            'url' => h($url),
            'message' => $error->getMessage(),
            'error' => $error,
            'errorCount' => $error->getValidationErrorCount(),
            'errors' => $error->getValidationErrors(),
            '_serialize' => ['code', 'url', 'message', 'errorCount', 'errors']
        ];
        $this->controller->set($sets);

        return $this->_outputMessage('error400');
    }
public function validation($error)
    {
        $url = $this->controller->request->getRequestTarget();
        $status = $code = $error->getCode();
        try {
            $this->controller->response = $this->controller->response->withStatus($status);
        } catch (Exception $e) {
            $status = 422;
            $this->controller->response = $this->controller->response->withStatus($status);
        }

        $sets = [
            'code' => $code,
            'url' => h($url),
            'message' => $error->getMessage(),
            'error' => $error,
            'errorCount' => $error->getValidationErrorCount(),
            'errors' => $error->getValidationErrors(),
            '_serialize' => ['code', 'url', 'message', 'errorCount', 'errors']
        ];
        $this->controller->set($sets);

        return $this->_outputMessage('error400');
    }
public function validation ( $ error ) { $ url = $ this -> controller -> request -> getRequestTarget ( ) ; $ status = $ code = $ error -> getCode ( ) ; try { $ this -> controller -> response = $ this -> controller -> response -> withStatus ( $ status ) ; } catch ( Exception $ e ) { $ status = 422 ; $ this -> controller -> response = $ this -> controller -> response -> withStatus ( $ status ) ; } $ sets = [ 'code' => $ code , 'url' => h ( $ url ) , 'message' => $ error -> getMessage ( ) , 'error' => $ error , 'errorCount' => $ error -> getValidationErrorCount ( ) , 'errors' => $ error -> getValidationErrors ( ) , '_serialize' => [ 'code' , 'url' , 'message' , 'errorCount' , 'errors' ] ] ; $ this -> controller -> set ( $ sets ) ; return $ this -> _outputMessage ( 'error400' ) ; }
Renders validation errors and sends a 422 error code

@param \Crud\Error\Exception\ValidationException $error Exception instance
@return \Cake\Http\Response
Renders validation errors and sends a 422 error code