Disabling HTML5 Form Validation For Laravel Dusk Tests
– cwhite.me - submitted by Chris White
Disabling client-side browser validation will allow you to test your real validation rules, instead of Chrome's.
Read more [cwhite.me]
– cwhite.me - submitted by Chris White
Disabling client-side browser validation will allow you to test your real validation rules, instead of Chrome's.
Read more [cwhite.me]
?You can mutate request data using @laravelphp 's form requests instead of doing it in the controller. By overwriting the validationData() method, you can mutate data BEFORE validation. Overwrite the validated() method to mutate AFTER validation. #Laravel #php pic.twitter.com/VAVXYAHCFC
— Neil Keena (@neilkeena) November 4, 2019
Read more [twitter.com]
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
"Always fresh, useful tips and articles. Carefully selected community content. My favorite newsletter, which I look forward to every time."
I'm a big fan of this approach and use Form Request like this quite often.
Let me show you what form requests can do for you - and how you can make use of them to write beautiful, expressive APIs.
Read more [pociot.dev]
Stefan Bauer explains how to handle error message when you have multiple forms on one page
Here's another tip! Even if it's documented here I just wanted to show it. Here's the deal: Imagine you have multiple forms one page. For example one contact form and another newsletter signup form. Both of them might have an email field. So who do you know which email field doesn't validate and throws an error?
Read more [stefanbauer.me]
? In @laravelphp you can customize validation error messages in a form request ? pic.twitter.com/8XFUeuqFOT
— Freek Van der Herten ? (@freekmurze) July 10, 2019
Read more [twitter.com]
laravel-validation-rules is a package that contains handy custom validation rules that are being used in various client projects we made at Spatie. Last week I added a new validate rule called Delimited to the package.
In this blog post, I'd like to explain why we added it and how it can be used.
? Tip: sometimes I want to perform a quick validation check outside of the normal “Validator” flow and then respond with the same HTTP response format the validator would use. You can easily do this using “ValidationException::withMessages()”… #HiddenGem pic.twitter.com/1Du0e8yrSH
— Taylor Otwell ⚗️ (@taylorotwell) January 17, 2019
Read more [twitter.com]
? #LaravelTip You can override the validationData method on your custom FormRequest class if you need to modify the request data _before_ it's validated against. #laravel pic.twitter.com/GoVw93sSrD
— Glenn Kimble Jr (@GlennKimbleJr) September 8, 2018
Read more [twitter.com]
? Customizing the error bag on a Laravel form request is as easy as setting a property. I find this comes in handy if a template might have multiple error checks. pic.twitter.com/b0lsP5oJ6G
— Paul Redmond ?? (@paulredmond) 26 juni 2018
Read more [twitter.com]
In an older, but still very interesting article, Mattias Verraes has some interesting thoughts on form, command and model validation.
Many of the frameworks I’ve worked with, promise to separate responsibilities with MVC. In practice, they end up coupling everything to everything. The forms are coupled to the models, and there’s a grand unified validation layer. This may be convenient at first, but it breaks down for larger systems, and creates headaches when having to support multiple clients. My approach is to clearly separate the validation for the form itself, from the Command validation and the model validation.
http://verraes.net/2015/02/form-command-model-validation/
???? Forgot about this little validation trick that had snuck by undocumented. pic.twitter.com/Hb5QUJY3ix
— Taylor Otwell ????♂️ (@taylorotwell) February 11, 2018
Read more [twitter.com]
Dave Rupert, lead developer at Paravel, shows how you can leverage native form validation and still style your errors using only a couple of lines of JavaScript.
If you’ve ever experimented with HTML5 Form Validation, you’ve probably been disappointed. The out-of-box experience isn’t quite what you want. Adding the required attribute to inputs works wonderfully. However the styling portion with input:invalid sorta sucks because empty inputs are trigger the :invalid state, even before the user has interacted with the page. I finally sat down and spent a couple days trying to make HTML5 Form Validation work the way I want it.
https://daverupert.com/2017/11/happier-html5-forms/
This works in Laravel 5.5 because $request->validate() only returns the validated data. Beautiful.
Yeah. I had originally sent that PR. I love it. Makes for these lovely controller methods. Just look at this❗ pic.twitter.com/FlxIlJVQXN
— Joseph Silber (@joseph_silber) September 14, 2017
Read more [twitter.com]
Imagine you're building an single page application that has a couple of forms. How are you going to validate those forms? Because we don't want to refresh the page submitting the form as usual isn't possible. Adding validation logic to the JavaScript side of things would just duplicate the…
Mohamed Said explains the not so well known sometimes validation rule in Laravel.
Laravel's validation library is very powerful and easy to use, using a few keystrokes you can build a strong defence around your application, preventing invalid user input from corrupting the application flow and potentially introducing bugs....
In this post I'd like to highlight a trick related to conditionally adding validation rules.
http://themsaid.com/laravel-advanced-validation-conditionally-adding-rules-20170110/
To learn more read the relevant section in the Laravel docs.
In a gist on GitHub Adam Wathan shares some macros that can be used to clean up a request.
Allows you to trim things, lowercase things, whatever you want. Pass a callable or array of callables that each expect a single argument:
Request::macro('filter', function ($key, $filters) {
return collect($filters)->reduce(function ($filtered, $filter) {
return $filter($filtered);
}, $this->input($key));
});
https://gist.github.com/adamwathan/610a9818382900daac6d6ecdf75a109b
If you want to hear Adam talk some more about troubles with requests (generated by webforms) and possible solutions, listen to this episode of the Full Stack Radio Podcast.
Sebastian De Deyne on his blog:
Dynamic languages allow us to pass anything as a parameter without requiring a specific type. In turn, this means we often need to handle some extra validation for the data that comes in to our objects.https://sebastiandedeyne.com/posts/2016/normalize-your-values-on-inputThis is a lightweight post on handling your incoming values effectively by normalizing them as soon as possible. It's a simple guideline worth keeping in mind which will help you keep your code easier to reason about.
Laravel ships with some good validation capabilities. Form request validation is a nice way to make sure http requests pass valid data. To validate stuff that enters the application in some other way validators can be created manually. Unfortunately this is kinda verbose: $validator =…
"Password must contain 1 uppercase letter, 1 lowercase letter, and 1 number."http://ryanwinchester.ca/post/stop-forcing-your-arbitrary-password-rules-on-meWith a rule like that, the password
Abcd1234would pass your validation, butmu-icac-of-jaz-doadwould not.
Ryan makes an excellent suggestion to replace password rules by an entropy estimator like Zxcvbn.