Athul Joy
Athul Joy

Reputation: 33

express-validator email normalization

I am using express-validator 6.9.2 for my Nodejs project. But when I used normalizeEmail() in my auth controller one of my test email "[email protected]" is stored in dB as "[email protected]". When I tried to log in to my app using [email protected] and [email protected] I was able to log in successfully. But when trying to create a new user with the email [email protected]. It shows an error email already exists. How can I normalize my email and store as "[email protected]" in dB?

Upvotes: 1

Views: 1400

Answers (1)

Farrukh Normuradov
Farrukh Normuradov

Reputation: 1194

In the options that you pass your validator you need to set property gmail_remove_dots to false. Here is the documentation.

check('email').normalizeEmail({gmail_remove_dots:false})

Upvotes: 1

Related Questions