Symfony formbuilder: validate email domain?

1k Views Asked by At

it's possible on a email filed (form builder) to restric some domains like "@gmail.com"?

I want to acept only some email in registration form.

3

There are 3 best solutions below

0
On

You can first play with Symfony EmailValidator:

https://symfony.com/doc/current/reference/constraints/Email.html

Or you can use something like that, playing with custom constraint:

https://stackoverflow.com/a/36452969/8526318

0
On

Yes. It is possible. Try use Validation.

0
On

Finally I haved tried to create a custom constrain validator like this:

https://stackoverflow.com/a/36452969/8526318