`normalizedEmail` / `normalizedPhone` for consistent identity
Avoid duplicate users from inconsistent input.
Alice@Example.com and alice@example.com should resolve to the same user. The library exports two helpers and uses them internally; you should call them from your own code paths too — anywhere a user submits an email or phone.
The function trims and lowercases. (It does not normalize Gmail-style + aliases — by design; those are user choices, not system noise.)
Phone
The phone normalizer strips formatting and ensures E.164. If your default country isn't US, set it on phoneAuth.defaultCountry.
Where to call them
- Forms — normalize on blur so the user sees the canonical form before submit.
- API boundaries — normalize again server-side, never trust the client's normalization.
- DB lookups — when you query
nest_auth_usersfrom custom code, normalize first. - Imports — when migrating users from another system, normalize on the way in.
Indexing
Postgres lets you put the normalization in a generated column:
Then your queries lowercase before comparing automatically. The library already does this on nest_auth_users.email.