logo
podcast Podcast
get help Get Unstuck

Even simple validation rules have nuances

Is anything truly simple in programming?

Joel Clermont
Joel Clermont
2025-07-16

Today is day two of validation tips pulled from the just-released 3rd edition of the Mastering Laravel Validation Rules book.

I like this tip because it shows how even simple validation rules can have nuances that we need to consider.

For example, what could be simpler than the uppercase rule?

We know what uppercase means. We learned this in our first years of school.

Consider some examples though:

$rules = ['field' => 'uppercase'];

// passes
$input = ['field' => 'LARAVEL'];

// passes, even though it has a number
$input = ['field' => 'PHP84'];

// passes, even though it has punctuation
$input = ['field' => 'PHP8.4!'];

Uppercase letters seem easy enough. We just have to remember that numbers and punctuation are ignored.

Let's try some more examples:

$rules = ['field' => 'uppercase'];

// passes: non-ASCII, but still uppercase
$input = ['field' => 'ÖÄÜ-123'];

// passes: non-Latin alphabets have uppercase too
$input = ['field' => 'ΑΝΤΙΣΤΡΟΦΗ'];

// alphabets without the concept of case still pass
$input = ['field' => '中文'];

// emoji pass too
$input = ['field' => '😂'];

The uppercase rule ignores any type of character that doesn't have the concept of case.

This makes sense, but it's a great example of how even simple validation rules can have nuances that we need to consider.

Here to help,

Joel

P.S. I challenge you to buy our validation book and read it cover to cover without learning something new and surprising.

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.