Black Friday: the Laravel testing course is $149 instead of $249, through Dec 7. See the course →
logo

Alpha validation might not be doing what you think

It certainly surprised me the first time I bumped into it

Joel Clermont
Joel Clermont
2024-02-14

From our daily Laravel tips email. Get the next one in your inbox.

Something that many developers find surprising is that the alpha validation rule doesn't just accept letters in the Roman alphabet (A-Z), but also includes thousands of Unicode characters like ƛ, ⱆ and আ.

Since Laravel 9, there's a modifier you can pass to the validation rule if you really only want A-Z characters to be accepted. Change your rule to alpha:ascii to change the behavior. Very cool!

Here to help,

Joel

P.S. This is just one of hundreds of interesting facts we share about validation in our book: Mastering Laravel Validation Rules.

Want a tip like this in your inbox every weekday?

Each one takes less than 2 minutes to read. Join 4,000+ Laravel developers who already get them.

email
No spam. Only real-world advice.
Toss a coin in the jar if you found this helpful.