简体   繁体   中英

Symfony formbuilder: validate email domain?

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.

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

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

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

Yes. It is possible. Try use Validation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM