validator icon indicating copy to clipboard operation
validator copied to clipboard

Email doesn't allow +s

Open robinjoseph08 opened this issue 6 years ago • 4 comments

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"`
}

robinjoseph08 avatar May 29 '19 05:05 robinjoseph08

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 :)

deankarn avatar Jul 10 '19 15:07 deankarn

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!

JonathanWThom avatar Dec 24 '19 21:12 JonathanWThom

I also confirmed that v10 works for "[email protected]". 👍

doi-t avatar Jun 05 '20 16:06 doi-t

If this works with v10 I suppose it's fine to close this issue?

zemzale avatar Jan 18 '22 06:01 zemzale

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.

jmvbxx avatar Dec 25 '22 15:12 jmvbxx