env-var icon indicating copy to clipboard operation
env-var copied to clipboard

add asMailString()

Open RodrigoDornelles opened this issue 3 years ago • 3 comments

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 avatar Aug 18 '21 23:08 RodrigoDornelles

@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?

evanshortiss avatar Aug 20 '21 09:08 evanshortiss

i think so, i'm not very familiar with regex and am typescript's noob, but i'll try anyway... carefully review my PR!

RodrigoDornelles avatar Aug 20 '21 12:08 RodrigoDornelles

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.

bigen1925 avatar Aug 09 '22 03:08 bigen1925

Released this in version 7.2.0. Thank you all.

evanshortiss avatar Aug 31 '22 22:08 evanshortiss