In this episode, we're checking out the new fluent rule for email validation in Laravel. First, we quickly go over what "fluent rules" are—basically, it's a way of chaining methods together to define validation rules in a more readable and flexible way. If you've seen how password validation works, for example, with things like min
, mixedCase
, and checking for compromised passwords, it's very much the same idea!
Now, Laravel has added these fluent rules for email validation, too. Instead of having to use the old-school syntax like 'email:dns,strict'
, you can chain methods such as dns()
and strict()
directly onto your email rule. This makes your validation more expressive and easier to read. We go through some practical examples, like validating that the domain of an email actually exists (using DNS/MX checks), or enforcing strict RFC validation.
We also do a quick demo where we try registering with an invalid domain and get to see the validation error in action. If you're already using these options, switching to the fluent syntax will make your code a bit cleaner and simpler to extend in the future. That's the scoop on the new fluent-style email validation in Laravel!