Email doesn't allow +s
Package version eg. v8, v9:
v9
Issue, Question or Enhancement:
When using the email validator, it doesn't allow values with + before the @ which is a common thing Gmail allows you to do. For example, [email protected] fails validation.
Code sample, to showcase or reproduce:
type loginParams struct {
Email string `form:"email" json:"email" mod:"lcase,trim" validate:"required,email"`
Password string `form:"password" json:"password" validate:"required,min=8"`
}
Thanks for pointing this out @robinjoseph08
It will likely be a bit before I can look into it, happy to accept a PR in the meantime though :)
For what it's worth, I wasn't able to replicate this with the following code:
package main
import (
"fmt"
"gopkg.in/go-playground/validator.v9"
)
type loginParams struct {
Email string `form:"email" json:"email" mod:"lcase,trim" validate:"required,email"`
Password string `form:"password" json:"password" validate:"required,min=8"`
}
func main() {
validate := validator.New()
login := &loginParams{
Email: "[email protected]",
Password: "password",
}
err := validate.Struct(login)
if err != nil {
// nothing prints here
fmt.Println(err)
}
}
I know the issue was for v9, but it's worth noting that a test for "[email protected]" passes against v10.
Definitely possible that I'm missing something with the setup though!
I also confirmed that v10 works for "[email protected]". 👍
If this works with v10 I suppose it's fine to close this issue?
Thank you @robinjoseph08 for the original issue. Given that the issue no longer applies to the latest version v10 we're going to go ahead and close this. Please feel free to reopen if you have any follow up questions.