manojtm's avatar

Upgraded to Laravel V11 - changes in validation error messages

We had developed an application on Laravel version 8.x and PHP 8.0. We needed to upgrade to latest version of PHP and Laravel. So I created a new Laravel project using composer with PHP 8.3. Then manually moved the app/*, routes and other classes and files. I have also manually installed the composer dependencies. The app seems to be working fine. The issue is with the unit tests. There are number of validation errors are causing the issues. ex:

  • "message": "The given data was invalid."\n
  • "message": "The city must be a string. (and 3 more errors)"\n

When we checked the APIs the success scinarios are fine. There are changes in validation messages. Which causing unit test faliures.

Now, we can fix the unit tests. But the APIs are being used by many clients. And we can not request all of them to change. Is there any way to use the earlier versions of validations messages in API?

0 likes
2 replies
ubedthaheem's avatar

Laravel > 10.x has changes in the Rule, so you have to modify your custom rule or create new one for your model. here is a sample Rule

manojtm's avatar

@ubedthaheem Any way to make these generic at framework level? It is all most not practical to do it for all APIs and for all fields.

Please or to participate in this conversation.