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

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.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼

Level up your Laravel skills!

Each 2-minute email has real-world advice you can use.