logo
podcast Podcast
get help Get Unstuck

A breaking change in the prohibited rule

In a patch version update

Joel Clermont
Joel Clermont
2025-08-26

Today's tip is a reminder that things can change in unexpected ways, even in patch versions of Laravel.

One example was a fairly significant behavior change in the prohibited validation rule during the Laravel 9 release cycle.

Up until version 9.48.0, this test would have passed:

$validator = Validator::make(
    ['field' => []], // data being validated
    ['field' => 'prohibited'] // rules being enforced
);

$this->assertTrue($validator->fails());

But when you update to 9.49.0 or later, this test will start failing. Why?

You can think of the prohibited rule as enforcing that a field is either not present at all, or if it is present, that it is "empty". It was the definition of "empty" that changed starting in 9.49.0.

Here's a table showing what is considered "empty" for the prohibited rule before and after the change:

< 9.49.0 >= 9.49.0
'' (empty string) '' (empty string)
null
[]
empty Countable
empty UploadedFile

To be clear, I'm not taking issue with the change. This rule became more internally consistent with other validation rules when the change was made.

I mainly wanted to highlight it because sometimes we assume nothing will break unless we're moving to a major version of a new Composer package.

History has proved to me many times that this cannot be guaranteed. This is one of many reasons why I believe so strongly in testing.

Here to help,

Joel

P.S. This tip is just one tidbit of hundreds like it in our validation book. I guarantee you'll learn something new and surprising if you read it.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.