mirror of
https://github.com/astaxie/beego.git
synced 2024-12-23 06:40:49 +00:00
Merge pull request #2494 from miraclesu/develop
validation: fix email valid
This commit is contained in:
commit
46f3ea4f43
@ -214,6 +214,12 @@ func TestEmail(t *testing.T) {
|
||||
if !valid.Email("suchuangji@gmail.com", "email").Ok {
|
||||
t.Error("\"suchuangji@gmail.com\" is a valid email address should be true")
|
||||
}
|
||||
if valid.Email("@suchuangji@gmail.com", "email").Ok {
|
||||
t.Error("\"@suchuangji@gmail.com\" is a valid email address should be false")
|
||||
}
|
||||
if valid.Email("suchuangji@gmail.com ok", "email").Ok {
|
||||
t.Error("\"suchuangji@gmail.com ok\" is a valid email address should be false")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIP(t *testing.T) {
|
||||
|
@ -518,7 +518,7 @@ func (a AlphaDash) GetLimitValue() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
var emailPattern = regexp.MustCompile("[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[a-zA-Z0-9](?:[\\w-]*[\\w])?")
|
||||
var emailPattern = regexp.MustCompile("^[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[a-zA-Z0-9](?:[\\w-]*[\\w])?$")
|
||||
|
||||
// Email check struct
|
||||
type Email struct {
|
||||
|
Loading…
Reference in New Issue
Block a user