Is there a way to configure UniqueEntity to treat foo
and Foo
as duplicates?
Use case: I have @UniqueEntity("email")
on my user entity, since I'm using the email address as username. According to https://stackoverflow.com/a/9808332/1668200 the local part of an email address is case-sensitive in theory, but case-insensitive in practice.
I could certainly convert it to lowercase in setEmail()
(as suggested at
https://stackoverflow.com/a/31663365/1668200). Drawbacks:
- Might confuse users (since their email address gets "modified")
- As a comment of the above answer says:
That's not a good idea, since there is a small chance it will not get delivered.
So I'd rather reject the user Foo@example.com
's registration (if foo@example.com
is already present), than convert all users' addresses to lowercase.