File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -129,8 +129,12 @@ public function appendRequestRules(array $controllersInfo)
129129 if ($ requestClass instanceof FormRequest) {
130130 try {
131131 $ controllersInfo [$ index ]['rules ' ] = $ this ->flattenRules ($ requestClass ->rules ());
132- } catch (Exception $ th ) {
133- $ controllerInfo [$ index ]['rules ' ] = $ this ->rulesByRegex ($ requestClassName );
132+ } catch (Exception $ e ) {
133+ // disabled. This only works when the rules are defined as 'required|integer' and that too in single line
134+ // doesn't work well when the same rule is defined as array ['required', 'integer'] or in multiple lines such as
135+ // If your rules are not populated using this library, then fix your rule to only throw validation errors and not throw exceptions
136+ // such as 404, 500 inside the request class.
137+ // $controllersInfo[$index]['rules'] = $this->rulesByRegex($requestClassName);
134138 }
135139 $ controllersInfo [$ index ]['docBlock ' ] = $ this ->lrdDocComment ($ reflectionMethod ->getDocComment ());
136140 }
@@ -196,6 +200,7 @@ public function rulesByRegex($requestClassName)
196200 $ data = new ReflectionMethod ($ requestClassName , 'rules ' );
197201 $ lines = file ($ data ->getFileName ());
198202 $ rules = [];
203+
199204 for ($ i = $ data ->getStartLine () - 1 ; $ i <= $ data ->getEndLine () - 1 ; $ i ++) {
200205 preg_match_all ("/(?:'| \").*?(?:'| \")/ " , $ lines [$ i ], $ matches );
201206 $ rules [] = $ matches ;
You can’t perform that action at this time.
0 commit comments