Normalize email sanitizing only gmail dots

#1

Hi there :slight_smile:

Is it possible to use sanitization rule for email and only remove dots when email is gmail domain?

For example:

email: ‘normalize_email’ will always remove dots, so emails like john.doe@notgmailcom will not be correct at all
while with rule email: ‘normalize_email:!rd’ this will work but it will allow users to have multiple accounts with same email if they use gmail. Because john.doe@gmailcom is infact the same as johndoe@gmailcom and even j.o.h.n.d.o.e@gmailcom

This lib https://github.com/chriso/validator.js#sanitizers has additional config options that can handle this. Is this possible in adonis without extending validator?

btw. couldnt create topic because new users cant add more then 2 links inside topic… email were recognized as links so they are without .com

0 Likes

#2

If anyone had issues with this… Since @adonisjs/validator 5.0.0 this is solved!

Gmail dots are removed on normalize email, other emails stays untouched.

Only problem… It looks like syntax changed a bit… normalize_email:!rd will throw an error:

Cannot create property 'all_lowercase' on string '!rd'

So take care :slight_smile:

0 Likes

#3

Here are docs on same http://indicative.adonisjs.com/docs/normalizeemail

0 Likes