env-var
env-var copied to clipboard
add asMailString()
Is your feature request related to a problem? Please describe. is something interesting, there is an email validation when string, I would liken [...]
Describe the solution you'd like do a regex validation over email, someone can refine it in the future and check IDN and DNS
Additional context
const email = env.get('MAIL_USER').asMailString();
@RodrigoDornelles this is a good suggestion. I've had to do this before, though I was lazy and used asString()
.
The one issue with this is how strict the implementation is. There are a few good suggestions in this StackOverflow post and this one too.
Personally I would accept a PR that does a simple regex, then mention this in the module docs. Aiming for full RFC compliance is not necessary since it would require using a third party module like this one or potentially complex code.
Do you want to open a PR?
i think so, i'm not very familiar with regex and am typescript's noob, but i'll try anyway... carefully review my PR!
Hi guys,
Thank you for providing this simple and awesome library, I love this. :D
And I will be also happy if this feature will be implemented, but there seems to be no progress in months, so I opened a PR.
https://github.com/evanshortiss/env-var/pull/158
I'm happy to be reviewed.
Released this in version 7.2.0. Thank you all.