authboss icon indicating copy to clipboard operation
authboss copied to clipboard

Validate email address with ParseAddress

Open darksnow opened this issue 2 years ago • 2 comments

Is it possible to validate email addresses using the Go built in ParseAddress function instead of a regexp?

Looking at https://cs.opensource.google/go/go/+/master:src/net/mail/message.go shows how complex correctly validating an email address is but I can't see a way to use that function in Authboss, or any regexp in the above code that I can apply to MustMatch.

Perhaps a good solution could be to add a ValidationFunction option to Rules which takes a func(string) bool

darksnow avatar Jan 13 '23 21:01 darksnow

https://cs.opensource.google/go/go/+/master:src/net/mail/message.go https://cs.opensource.google/go/go/+/master:src/net/mail/message.go;drc=b2faff18ce28edad98303d2c3134dec1331fd7b5 src/net/mail/message.go open-pull-requests-limit

Botino888 avatar Feb 25 '23 14:02 Botino888

Sounds like a good idea.

I think we could add a bool to opt out of this functionality, but have it turned on by default and use our license for breaking changes to introduce this in a minor. It shouldn't be processing invalid ones already. Welcome a PR for this.

aarondl avatar Mar 13 '23 03:03 aarondl