Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[L5.4] BadMethodCallException Method [explodeRules] does not exist. #245

Closed
Omranic opened this issue Jun 15, 2017 · 9 comments · Fixed by #330
Closed

[L5.4] BadMethodCallException Method [explodeRules] does not exist. #245

Omranic opened this issue Jun 15, 2017 · 9 comments · Fixed by #330

Comments

@Omranic
Copy link
Contributor

Omranic commented Jun 15, 2017

Trying to implement Conditional Validation resulting the following error:
BadMethodCallException Method [explodeRules] does not exist.

Tested with both Laravel 5.4 & 5.5 with master branch of this package. Same error on both. Any suggestions?

Observation: This package is calling explodeRules on the Illuminate\Validation\Validator which doesn't have this method, while this method exists on Illuminate\Validation\ValidationRuleParser.

Update the illuminate validation component has been refactored on Laravel 5.4, check laravel/framework#17005 so this package's functionality depends on L5.3, and need to be updated. I'd like it if I've some time to contribute a PR, but not sure if that's possible soon. Any suggestions..?

Error Trace:

<!--
BadMethodCallException: Method [explodeRules] does not exist. in file /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Validation/Validator.php on line 1139
Stack trace:
  1. BadMethodCallException->() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Validation/Validator.php:1139
  2. Illuminate\Validation\Validator->__call() /home/vagrant/Code/rinvex/cortex/vendor/proengsoft/laravel-jsvalidation/src/Support/AccessProtectedTrait.php:21
  3. call_user_func_array() /home/vagrant/Code/rinvex/cortex/vendor/proengsoft/laravel-jsvalidation/src/Support/AccessProtectedTrait.php:21
  4. Illuminate\Validation\Validator->Proengsoft\JsValidation\Support\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/proengsoft/laravel-jsvalidation/src/Support/AccessProtectedTrait.php:60
  5. call_user_func() /home/vagrant/Code/rinvex/cortex/vendor/proengsoft/laravel-jsvalidation/src/Support/AccessProtectedTrait.php:60
  6. Proengsoft\JsValidation\Support\DelegatedValidator->callProtected() /home/vagrant/Code/rinvex/cortex/vendor/proengsoft/laravel-jsvalidation/src/Support/DelegatedValidator.php:54
  7. Proengsoft\JsValidation\Support\DelegatedValidator->callValidator() /home/vagrant/Code/rinvex/cortex/vendor/proengsoft/laravel-jsvalidation/src/Support/DelegatedValidator.php:170
  8. Proengsoft\JsValidation\Support\DelegatedValidator->explodeRules() /home/vagrant/Code/rinvex/cortex/vendor/proengsoft/laravel-jsvalidation/src/Javascript/RuleParser.php:96
  9. Proengsoft\JsValidation\Javascript\RuleParser->addConditionalRules() /home/vagrant/Code/rinvex/cortex/vendor/proengsoft/laravel-jsvalidation/src/Javascript/ValidatorHandler.php:168
 10. Proengsoft\JsValidation\Javascript\ValidatorHandler->sometimes() /home/vagrant/Code/rinvex/cortex/vendor/proengsoft/laravel-jsvalidation/src/Javascript/JavascriptValidator.php:225
 11. Proengsoft\JsValidation\Javascript\JavascriptValidator->sometimes() /home/vagrant/Code/rinvex/cortex/app/cortex/fort/src/Http/Controllers/Backend/UsersController.php:89
 12. Cortex\Fort\Http\Controllers\Backend\UsersController->form() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
 13. call_user_func_array() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
 14. Illuminate\Routing\Controller->callAction() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:44
 15. Illuminate\Routing\ControllerDispatcher->dispatch() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Route.php:203
 16. Illuminate\Routing\Route->runController() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Route.php:160
 17. Illuminate\Routing\Route->run() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Router.php:582
 18. Illuminate\Routing\Router->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
 19. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authorize.php:57
 20. Illuminate\Auth\Middleware\Authorize->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 21. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 22. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/app/cortex/foundation/src/Http/Middleware/Authenticate.php:30
 23. Cortex\Foundation\Http\Middleware\Authenticate->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 24. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 25. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authorize.php:57
 26. Illuminate\Auth\Middleware\Authorize->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 27. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 28. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/rinvex/fort/src/Http/Middleware/NoHttpCache.php:23
 29. Rinvex\Fort\Http\Middleware\NoHttpCache->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 30. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 31. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/app/cortex/tenantable/src/Http/Middleware/Tenantable.php:29
 32. Cortex\Tenantable\Http\Middleware\Tenantable->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 33. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 34. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/rinvex/fort/src/Http/Middleware/Abilities.php:38
 35. Rinvex\Fort\Http\Middleware\Abilities->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 36. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 37. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/app/cortex/foundation/src/Http/Middleware/Clockwork.php:46
 38. Cortex\Foundation\Http\Middleware\Clockwork->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 39. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 40. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/app/cortex/foundation/src/Http/Middleware/NotificationMiddleware.php:42
 41. Cortex\Foundation\Http\Middleware\NotificationMiddleware->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 42. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 43. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41
 44. Illuminate\Routing\Middleware\SubstituteBindings->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 45. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 46. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:65
 47. Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 48. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 49. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php:49
 50. Illuminate\View\Middleware\ShareErrorsFromSession->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 51. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 52. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:64
 53. Illuminate\Session\Middleware\StartSession->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 54. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 55. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37
 56. Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 57. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 58. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:59
 59. Illuminate\Cookie\Middleware\EncryptCookies->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 60. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 61. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/app/cortex/foundation/src/Http/Middleware/ForgetLocaleRouteParameter.php:24
 62. Cortex\Foundation\Http\Middleware\ForgetLocaleRouteParameter->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 63. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 64. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:102
 65. Illuminate\Pipeline\Pipeline->then() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Router.php:584
 66. Illuminate\Routing\Router->runRouteWithinStack() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Router.php:543
 67. Illuminate\Routing\Router->dispatchToRoute() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Router.php:521
 68. Illuminate\Routing\Router->dispatch() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:174
 69. Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
 70. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/proengsoft/laravel-jsvalidation/src/RemoteValidationMiddleware.php:54
 71. Proengsoft\JsValidation\RemoteValidationMiddleware->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 72. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 73. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/fideloper/proxy/src/TrustProxies.php:55
 74. Fideloper\Proxy\TrustProxies->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 75. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 76. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:30
 77. Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 78. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 79. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:30
 80. Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 81. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 82. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27
 83. Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 84. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 85. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:46
 86. Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
 87. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 88. Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:102
 89. Illuminate\Pipeline\Pipeline->then() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:149
 90. Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter() /home/vagrant/Code/rinvex/cortex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
 91. Illuminate\Foundation\Http\Kernel->handle() /home/vagrant/Code/rinvex/cortex/public/index.php:50

-->
@Omranic Omranic changed the title BadMethodCallException Method [explodeRules] does not exist. [5.4] BadMethodCallException Method [explodeRules] does not exist. Jun 15, 2017
@Omranic
Copy link
Contributor Author

Omranic commented Jun 15, 2017

Found a solution on one of the forks of this package, here's the patch hopefully it could make it's way to the master branch. Patch tested and working on both Laravel 5.5/5.4 too. Reference: https://github.com/reganjohnson/laravel-jsvalidation/pull/2

patch-for-conditional-rule-parser.patch.txt

@antonkomarev
Copy link
Contributor

antonkomarev commented Jun 15, 2017

@Omranic Thanks for the proposed solution. I've tried to apply it but it's breaking unit tests. Right now RuleParser class awaiting DelegatedValidator which has explodeRules method.
If we will apply the patch we will not use DelegatedValidator class. Sadly I'm not yet sure what tasks it solves.

Could you provide an example of code which fails to work?

@Omranic
Copy link
Contributor Author

Omranic commented Jun 15, 2017

Sure, I've used exactly this example: https://github.com/proengsoft/laravel-jsvalidation/wiki/Conditional-Validation-Example

$validationRules = [
    'email' => 'required|email',
    'games' => 'required|numeric',
];

$jsValidator = JsValidator::make($validationRules);
$jsValidator->sometimes('reason', 'required|max:500');

Whenever I write that last line $jsValidator->sometimes('reason', 'required|max:500'); with Laravel 5.4+ I get the above exception.

@jampack
Copy link

jampack commented Jun 15, 2017 via email

@Omranic
Copy link
Contributor Author

Omranic commented Jun 29, 2017

@a-komarev Any updates on this?

@antonkomarev antonkomarev changed the title [5.4] BadMethodCallException Method [explodeRules] does not exist. [L5.4] BadMethodCallException Method [explodeRules] does not exist. Jul 9, 2017
@antonkomarev
Copy link
Contributor

@Omranic No. Could you write unit tests for this case?

@antonkomarev antonkomarev added this to New Issues in laravel-jsvalidation Jul 11, 2017
@antonkomarev
Copy link
Contributor

@Omranic is this issue still exists? There were a lot of changes in dev-master.

@antonkomarev antonkomarev modified the milestones: 2.0.0, 2.1.0 Jul 11, 2017
@pingwiniasty
Copy link

@a-komarev Hi, it still exist on 5.5
I'm made some quick path for this in other fork
https://github.com/reganjohnson/laravel-jsvalidation/commit/6eed58932434f31fa476057e2773c01372ee826b

@ultrono
Copy link

ultrono commented Feb 6, 2018

Confirmed still an issue on 5.5.28 :/

bytestream pushed a commit to bytestream/laravel-jsvalidation that referenced this issue Jun 6, 2018
bytestream pushed a commit to bytestream/laravel-jsvalidation that referenced this issue Jun 6, 2018
bytestream pushed a commit to bytestream/laravel-jsvalidation that referenced this issue Jun 6, 2018
bytestream pushed a commit to bytestream/laravel-jsvalidation that referenced this issue Jun 6, 2018
bytestream pushed a commit to bytestream/laravel-jsvalidation that referenced this issue Jun 26, 2018
@bytestream bytestream linked a pull request Mar 13, 2020 that will close this issue
bytestream pushed a commit to bytestream/laravel-jsvalidation that referenced this issue Mar 15, 2020
bytestream added a commit that referenced this issue Mar 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

5 participants