I have no idea how to make validation rules for email field not accepting email free account like gmail, yahoo etc. Can anyone guide me on this topic. Thanks in advance
Laravel provides validation rules to validate input fields. You can check if an email is valid or not in Laravel using the validate method by passing in the validation rules. You can validate your email addresses using one or more of the validation rules we have discussed.
you can easily use bail validation in laravel 6, laravel 7, laravel 8 and laravel 9. If you added more then one validation on your field like required, integer, min and max then if first is fail then other should stop to display error message. right now by default it print other too.
Put a list of email providers into a config file, for example into the config/email.php
:
'banned_email_providers' => '@gmail\.com|@yahoo\.com'
Then use the regex
validation rule using this list:
'email' => ['regex:/^((?!' . config('email.banned_email_providers') . ').)*$/'],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With