Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] validate email with custom class #33835

Merged
merged 2 commits into from Aug 12, 2020
Merged

[7.x] validate email with custom class #33835

merged 2 commits into from Aug 12, 2020

Conversation

Gummibeer
Copy link
Contributor

@Gummibeer Gummibeer commented Aug 12, 2020

The underlying egulias/email-validator package allows to add custom validators by implementing the Egulias\EmailValidator\Validation\EmailValidation interface.
But right now it's not possible to use the existing email rule to call these custom validators.

This PR allows to pass in a FQCN which is resolved by the container and returned.

use App\Validation\Email\MyCustomValidator;

Validator::make(
  ['email' => 'foo@bar.de'], 
  ['email' => 'email:rfc,dns,'.MyCustomValidator::class]
)->passes();

This example will call the rfc and dns validator like before but also call MyCustomValidator.
That's useful if you want to limit registration to a given email domain, filter trashmails or whatever you want to add on top.

@Gummibeer Gummibeer changed the title validate email with custom class [7.x] validate email with custom class Aug 12, 2020
@taylorotwell taylorotwell merged commit 3da489c into laravel:7.x Aug 12, 2020
10 checks passed
@Gummibeer Gummibeer deleted the ft-validate-email-with-custom-class branch Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants