jaswdr / faker

:rocket: Ultimate fake data generator for Go with zero dependencies
https://pkg.go.dev/github.com/jaswdr/faker
MIT License
566 stars 59 forks source link

[BUG] Some fake emails fails email validation regex #83

Closed jcobhams closed 2 years ago

jcobhams commented 2 years ago

Describe the bug When using faker.Internet().Email(), some generated fake emails fails email regex patterns. Some names like "O\"Connell", "O\"Conner", "O\"Hara", "O\"Keefe", "O\"Kon" found in here trips up a regex pattern for validating email addresses.

Regex: /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/g

To Reproduce

In the off chance that you can get the library to pick one of these names and generate a fake email, you can run it against this regex validator: https://regexr.com/3e48o

Expected behavior That faker.Internet().Email() returns a semantically valid email address format.

Screenshots Screen Shot 2022-01-26 at 7 58 19 PM

Desktop (please complete the following information):

jaswdr commented 2 years ago

@jcobhams thank you for reporting 👍 , I've merged the fix for this issue and released it in 1.10.1, the fix will only generate names with valid characters, replacing with "_" otherwise, and includes a validation in tests to check that the email is valid to improve detection of this in the future.

jcobhams commented 2 years ago

Thanks for the quick fix and prompt response @jaswdr 🙏

babaralishah commented 2 years ago

Hi I am on Angular

And using the below regex:

'^[a-z0-9]+([._-]?[a-z0-9]+)+@[a-z0-9]+([._-]?[a-z0-9]+)+\\.[a-z]{2,3}$'

But its not fulfilling my requirement, my requirement is below:

saa5@me-d_d_u.co

please anyone tell me, why this regex is not working for my above mentioned case.

Regards Babar Ali Shah