Laravel Pro Tips
🔥 #Laravel Tip: Using custom error messages for failed request validation is straight out of the docs, but it’s amazing how rarely it gets used. Make your apps better and improve their UX by giving users more guidance in solving validation errors.
Matt Kingshott 🏝
#Laravel Validation Tip 🔥
You can use a closure instead of a rule object if you only need a custom rule once throughout your application.
The closure receives the attribute's name, the attribute's value, and a `fail` callback that should be called if validation fails.
🔥 #Laravel Tip: Sometimes you want to validate part of the request's data, but you don't actually need the data (and must make a point of filtering it out) e.g. a bool confirming the user accepts terms and conditions. In these situations, use the 'exclude' validation rule.
Laravel password validation rules are🔥
There's even an 'uncompromised' that checks the password in the 'have i been pwned' database:
Checkboxes are a pain to validate against because if they’re not checked they’re not present in the HTTP request. You can solve this by using a hidden input, but #Laravel makes it easy to set up a default in the Request. Now `$request->opt_in` is always true or false. #PHP #Code
The more I discover more about Laravel, the more I love it... You can check if a password has been uncompromised ?? :o
Noah Di Gesù
💡 Quick #Laravel validation tip.
If you want to make sure start and end dates in your forms are entered in the right order, the before_or_equal and after_or_equal rules got you covered.
But what if you want either of the dates to be nullable?
Rule::when() to the rescue! 🚀
Lupinity Labs | Freelance Software Dev 🕊 🇺🇦
Laravel Tip: While defining a Unique Validation Rule, you can also pass the Model Name instead of passing the Table Name. 🔥
The Laravel Dev
🔥 #Laravel Tip: Sometimes the default error messages returned when data validation fails are not always helpful in solving the problem. Fortunately, with form requests, we can supply our own error messages to make things clearer to the user.
Apr 6th, 2022
Validating arrays and nested values in Laravel
Validating arrays and nested values allows you to more effectively deal with data transmitted from your frontend.
Feb 6th, 2022
Laravel Validation: A Tale of Existence
One of my latest Laravel tips on Twitter, discussing Laravel validators for checking the existence of...