Laravel Validation: 12 Less-Known Tips in 13 Minutes

  Рет қаралды 38,073

Laravel Daily

Laravel Daily

Күн бұрын

In this video, I'm sharing some more rarely used tips about Laravel validation that I learned over my 5+ years with Laravel.
00:00 Intro
00:53 Tip 1. Required / Present / Filled
02:05 Tip 2. Required_with and Similar
03:06 Tip 3. Rules min/max for Numbers
03:48 Tip 4. Image Dimensions Validation
04:27 Tip 5. Date before Today/Yesterday
05:32 Tip 6. Separators, Arrays, Custom Rules
06:45 Tip 7. Component in Breeze/Jetstream
07:31 Tip 8. Change Error Messages
08:37 Tip 9. Change field Name in Errors
09:15 Tip 10. $request-all() Security Issue
10:45 Tip 11. Customize Form Request Default
12:00 Tip 12. Customize Error Pages
- - - - -
Support the channel by checking out our products:
- Try our Laravel QuickAdminPanel: bit.ly/quickadminpanel
- Enroll in my Laravel courses: laraveldaily.teachable.com
- Purchase my Livewire Kit: livewirekit.com
- Subscribe to my weekly newsletter: bit.ly/laravel-newsletter

Пікірлер: 76
@fahnleindieselschweif5022
@fahnleindieselschweif5022 3 жыл бұрын
You are my daily snack of knowledge. Nom nom nom!
@Claudio_Pereira
@Claudio_Pereira 3 жыл бұрын
Povilas, I can't get enough of saying this: your work helps me to improve as a Laravel developer. Thank you very much.
@OverBlockPlay
@OverBlockPlay 3 жыл бұрын
Tamo junto Cláudio
@alila3883
@alila3883 3 жыл бұрын
This Chanel is the best Chanel in Laravel... Thanks, Mr. Pvilas
@Somcoders
@Somcoders 3 жыл бұрын
After busy week, I was behind in 5 videos , now I'm uptodate xD
@Babaknouri
@Babaknouri Жыл бұрын
Excellent, Thanks a lot for your time and efforts
@niamreg_dev
@niamreg_dev 3 жыл бұрын
You are the best! Best channel on Laravel. A lot of knowledge. Thank you
@alnahian2003
@alnahian2003 Жыл бұрын
TBH, from this superb helpful video I learned a lot! Specially I never knew something like Fake Filler extension ever existed. It's really saving my time and improving my productivity. Thanks Dear Povilas 🧡
@GergelyCsermely
@GergelyCsermely 3 жыл бұрын
I learned again a lot. Keep doing :) Thank You!
@davidson7838
@davidson7838 3 жыл бұрын
Thanks surely we must support you by buying your products. :)
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Much appreciated!
@hatsushiroyuki8697
@hatsushiroyuki8697 3 жыл бұрын
Thanks for sharing, great video as always.
@MahmoudIsmail-en3nu
@MahmoudIsmail-en3nu 2 ай бұрын
Thank you very very much
@ArthurMoraisDev
@ArthurMoraisDev 3 жыл бұрын
Thank you Povilas! i've learned a lot!
@belce1982
@belce1982 2 жыл бұрын
Thanks as always!
@ridamakhchan
@ridamakhchan 3 жыл бұрын
You deserve big thanks, Thank you Povilas
@cloudergnu
@cloudergnu 3 жыл бұрын
Poop-ton of useful information in this video. Thanks for all the great content, really appreciate it
@programminggeekseth3797
@programminggeekseth3797 Жыл бұрын
Thank you so much , you are so amaizing
@ashwanisingh9283
@ashwanisingh9283 3 жыл бұрын
Thanks for this video sir..
@salimedia33
@salimedia33 3 жыл бұрын
Thank You very much :)
@margop3567
@margop3567 2 жыл бұрын
Try to use laravel validate and catch error in case file is bigger than upload_max_size or post_max_size!
@neerajsinghtangariya2587
@neerajsinghtangariya2587 3 жыл бұрын
This is awesome :)
@rashidrumman871
@rashidrumman871 3 жыл бұрын
Custom validation error messages tip was really an eye-opener for me 😅 I thought I'd have to do manual validation to accommodate the client's required messages in three different languages 😬
@surflaweb
@surflaweb 3 жыл бұрын
Great.. I didnt know "present" rule.. Amazing
@nadeemahmed7947
@nadeemahmed7947 3 жыл бұрын
Bail in validation is very helpful
@a-ezzat5677
@a-ezzat5677 3 жыл бұрын
thank you , you are amazing
@AbrarAhmad-mz8vl
@AbrarAhmad-mz8vl 3 жыл бұрын
really helpful
@waqasmushtaq81
@waqasmushtaq81 3 жыл бұрын
Superb!
@nhantran3472
@nhantran3472 3 жыл бұрын
Awesome!
@msdeav
@msdeav 2 жыл бұрын
thank you...
@mibrahim4245
@mibrahim4245 Жыл бұрын
Hi .. this is the best channel I've ever seen .. do you have any courses on the internet ? .. THANKS
@LaravelDaily
@LaravelDaily Жыл бұрын
A lot of them, actually, go here: laraveldaily.teachable.com
Жыл бұрын
Hi to everyone! There is a way to validate a two fields unique combination? I'm in a project which need to validate a combination of slug and category (The user can choose the slug in the form) in order to avoid duplicated urls. Thanks in advance
@randomguy5922
@randomguy5922 3 жыл бұрын
Sir, please reply. One of my senior told me to use validations inside MODELS, but in Laravel, I generally use FORM-REQUESTS to validate data (I use the same form request for API and WEB requests), he a developer in some other language and told me that, if you will use validations in MODELS, you will not need to write separately validate request in API, SEEDERS, CONTROLLERS etc, you can use the model validation just from one place, check the validation at boot function while self::creating. So that anyone who tries to create any data using that model, validation must pass. What you think about this approach.
@bumblebity2902
@bumblebity2902 3 жыл бұрын
I have issue with sometimes rule. I don't present any value to password and I get validation error rule, although it should trigger if I present some value.
@debjit21
@debjit21 3 жыл бұрын
Thank you for sharing. I validate phone number using this method 'digits:10'. What you are using?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
For phone numbers, there are special validation libraries depending on the country: blog.quickadminpanel.com/phone-field-validation-with-laravel-phone-package/ I would advise to NOT validate it like digits, cause there are different formats to write a phone number, like (+370) 611 23566
@debjit21
@debjit21 3 жыл бұрын
@@LaravelDaily Thank you. It's very usefull. I will try it on my projects. But in this case it is just 10 digital number because it a local project, and only mobile number is needed.
@infureal
@infureal 3 жыл бұрын
You can get validated data not only from FormRequest. Simply do - $data = request()->validate([/*rules*/]); And in $data variable will be ONLY validated fields. It is usefull if you have unique validation rules in one place in your code
@igerardogc
@igerardogc 3 жыл бұрын
If u do that u dont use SOLID principles
@infureal
@infureal 3 жыл бұрын
@@igerardogc Yeap. But in video Povilas said that is no way to do that. I shoed that it's possible
@JaswinderSingh-cb4by
@JaswinderSingh-cb4by 3 жыл бұрын
Hello Sir, Can I used bootstrap instead of Tailwind in Jetstream ? If yes then how can used it.
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Yes, with Jetstrap: kzbin.info/www/bejne/hpWadnlop9Csha8
@shadowsurounds
@shadowsurounds 11 ай бұрын
question on $request->validated() 10:04 I tried it once and it didn't work. I then found out that the issue was that the Form Field "name" was different from the "Database Table" column name. So is there a way "out of the box" with Laravel to have the form field name="user_name" while the database table column name can be "name" and still make this work?
@LaravelDaily
@LaravelDaily 11 ай бұрын
In form request class you can manipulate with prepareForValidation()
@Stoney_Eagle
@Stoney_Eagle 3 жыл бұрын
How can I use the age minimum restriction with a date field? Something like a (date now - filled date) >= 18, or is there a better way.
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Something like "before:" . now()->subYears(18)->toDateString()
@Stoney_Eagle
@Stoney_Eagle 3 жыл бұрын
@@LaravelDaily thanks!
@Stoney_Eagle
@Stoney_Eagle 3 жыл бұрын
@@LaravelDaily Sorry to bother you again but I have my laravel app translated on Middleware level, so on request it checks for the browser language or api accept language header. But the :date placeholder value from my translation file is not localized in the error message. My browser asks for day month year but the error says must be before year month date (in Dutch), witch is confusing for users. Where can I change this behavior? I don't want to confuse English speakers either by hard-coding it the other way like you wrote in your blog article.
@NotBeHaris
@NotBeHaris 3 жыл бұрын
Sir i have a question that how we validate unique email when we want to update user.
@gustavovasquezveliz7046
@gustavovasquezveliz7046 3 жыл бұрын
Rule::unique('users')->ignore($user->id)
@blokkaliwon7794
@blokkaliwon7794 2 жыл бұрын
Sir, how to make unique validation of 2 or 3 fields in controller. ? So when inputting the same data on 2 or 3 fields a notification will appear that the inputted data already exists.
@LaravelDaily
@LaravelDaily 2 жыл бұрын
I would create a custom validation rule for this.
@blokkaliwon7794
@blokkaliwon7794 2 жыл бұрын
@@LaravelDaily do you have example video for this.
@LaravelDaily
@LaravelDaily 2 жыл бұрын
On custom rules, yes: kzbin.info/www/bejne/gV7Yp3ykYpmInZI
@blokkaliwon7794
@blokkaliwon7794 2 жыл бұрын
@@LaravelDaily thanks sir.
@alimahdavi9775
@alimahdavi9775 3 жыл бұрын
Nice 👌 Tip 10 and 11 title not shown in video
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Hm, interesting, will be more careful editing next time.
@mindaugasvirbickis4061
@mindaugasvirbickis4061 3 жыл бұрын
Hi. Offtopic. How to return response json from Request Form ?
@guramikutivadze
@guramikutivadze 3 жыл бұрын
Better then $request->validated() is to use DTO but it doesn't means that validation is not required.
@rizkihutama5633
@rizkihutama5633 3 жыл бұрын
can i use $request->validated() without form request? i use $request->validate() can i do with this method?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Yes
@rizkihutama5633
@rizkihutama5633 3 жыл бұрын
@@LaravelDaily how exactly i use this, any refrence will be great. Thanks
@muhammadfarhanahmed9280
@muhammadfarhanahmed9280 3 жыл бұрын
hi ,Povilas i need one vedio clip on user authentication with firebase and messaging with firebase..when you uplode this vedio?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Firebase is not in the near plans, sorry
@muhammadfarhanahmed9280
@muhammadfarhanahmed9280 3 жыл бұрын
When you made that clip?
@morte226
@morte226 3 жыл бұрын
Validated function is available in Validator::make!!!!
@shubhajeet10
@shubhajeet10 2 жыл бұрын
Hello Sir, I want to Validate One User Name... It may Either Email or Phone... I have two Regex... How to put OR condition in Laravel Validation... Thanks in Advance.
@LaravelDaily
@LaravelDaily 2 жыл бұрын
If you have two regexes, probably you combine them into one regex?
@shubhajeet10
@shubhajeet10 2 жыл бұрын
@@LaravelDaily Thank you so much for your Reply.
@raimonds.L
@raimonds.L 3 жыл бұрын
can you just write __('Name is required') ?
@a-ezzat5677
@a-ezzat5677 3 жыл бұрын
your explanation is not complicated and simple to be understood
@joaocagnoni1
@joaocagnoni1 3 жыл бұрын
3:18 just another developer creating 18+ websites
9 Tips for Shorter Laravel Code
10:16
Laravel Daily
Рет қаралды 61 М.
Junior Code Review: Laravel Routes, Middleware, Validation and more
19:57
The child was abused by the clown#Short #Officer Rabbit #angel
00:55
兔子警官
Рет қаралды 23 МЛН
Я нашел кто меня пранкует!
00:51
Аришнев
Рет қаралды 3,4 МЛН
🌊Насколько Глубокий Океан ? #shorts
00:42
Неприятная Встреча На Мосту - Полярная звезда #shorts
00:59
Полярная звезда - Kuzey Yıldızı
Рет қаралды 7 МЛН
Laravel SPA Authentication - setup and common mistakes
16:55
18 Laravel/PHP Tips in 10 Minutes: June 2024
10:41
Laravel Daily
Рет қаралды 6 М.
PHP is the future
34:27
Aaron Francis
Рет қаралды 168 М.
Junior Developer Sent Me A PR For Review
17:26
Amigoscode
Рет қаралды 166 М.
Exceptions in Laravel: Why/How to Use and Create Your Own
12:18
Laravel Daily
Рет қаралды 86 М.
Laravel Eloquent: Deeper Relationships with One Query
10:37
Laravel Daily
Рет қаралды 137 М.
Laravel Service Providers: All You Need to Know
13:13
Laravel Daily
Рет қаралды 64 М.
Laravel Controller Code: Move to Model, Service, Action or Job?
12:51
Laravel Daily
Рет қаралды 104 М.
Застрявшее Кольцо 🤯
0:26
MovieLuvsky
Рет қаралды 5 МЛН
Qual ELEMENTO é Melhor para ESCAPAR😱 #shorts
0:26
Lucan Pevidor
Рет қаралды 18 МЛН
Как люди тонут?
0:43
Silver Swim - Школа плавания
Рет қаралды 4,8 МЛН
CHARGING METHOD FOR CARDBOARD iPhone!#asmr
0:31
HAYATAKU はやたく
Рет қаралды 14 МЛН
Was ist im Eis versteckt? 🧊 Coole Winter-Gadgets von Amazon
0:37
SMOL German
Рет қаралды 32 МЛН