mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 18:20:54 +00:00
commit
6892369cc6
@ -268,6 +268,18 @@ func TestMobile(t *testing.T) {
|
|||||||
if !valid.Mobile("+8614700008888", "mobile").Ok {
|
if !valid.Mobile("+8614700008888", "mobile").Ok {
|
||||||
t.Error("\"+8614700008888\" is a valid mobile phone number should be true")
|
t.Error("\"+8614700008888\" is a valid mobile phone number should be true")
|
||||||
}
|
}
|
||||||
|
if !valid.Mobile("17300008888", "mobile").Ok {
|
||||||
|
t.Error("\"17300008888\" is a valid mobile phone number should be true")
|
||||||
|
}
|
||||||
|
if !valid.Mobile("+8617100008888", "mobile").Ok {
|
||||||
|
t.Error("\"+8617100008888\" is a valid mobile phone number should be true")
|
||||||
|
}
|
||||||
|
if !valid.Mobile("8617500008888", "mobile").Ok {
|
||||||
|
t.Error("\"8617500008888\" is a valid mobile phone number should be true")
|
||||||
|
}
|
||||||
|
if valid.Mobile("8617400008888", "mobile").Ok {
|
||||||
|
t.Error("\"8617400008888\" is a valid mobile phone number should be false")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTel(t *testing.T) {
|
func TestTel(t *testing.T) {
|
||||||
@ -453,7 +465,7 @@ func TestPointer(t *testing.T) {
|
|||||||
|
|
||||||
u := User{
|
u := User{
|
||||||
ReqEmail: nil,
|
ReqEmail: nil,
|
||||||
Email: nil,
|
Email: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
valid := Validation{}
|
valid := Validation{}
|
||||||
@ -468,7 +480,7 @@ func TestPointer(t *testing.T) {
|
|||||||
validEmail := "a@a.com"
|
validEmail := "a@a.com"
|
||||||
u = User{
|
u = User{
|
||||||
ReqEmail: &validEmail,
|
ReqEmail: &validEmail,
|
||||||
Email: nil,
|
Email: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
valid = Validation{RequiredFirst: true}
|
valid = Validation{RequiredFirst: true}
|
||||||
@ -482,7 +494,7 @@ func TestPointer(t *testing.T) {
|
|||||||
|
|
||||||
u = User{
|
u = User{
|
||||||
ReqEmail: &validEmail,
|
ReqEmail: &validEmail,
|
||||||
Email: nil,
|
Email: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
valid = Validation{}
|
valid = Validation{}
|
||||||
@ -497,7 +509,7 @@ func TestPointer(t *testing.T) {
|
|||||||
invalidEmail := "a@a"
|
invalidEmail := "a@a"
|
||||||
u = User{
|
u = User{
|
||||||
ReqEmail: &validEmail,
|
ReqEmail: &validEmail,
|
||||||
Email: &invalidEmail,
|
Email: &invalidEmail,
|
||||||
}
|
}
|
||||||
|
|
||||||
valid = Validation{RequiredFirst: true}
|
valid = Validation{RequiredFirst: true}
|
||||||
@ -511,7 +523,7 @@ func TestPointer(t *testing.T) {
|
|||||||
|
|
||||||
u = User{
|
u = User{
|
||||||
ReqEmail: &validEmail,
|
ReqEmail: &validEmail,
|
||||||
Email: &invalidEmail,
|
Email: &invalidEmail,
|
||||||
}
|
}
|
||||||
|
|
||||||
valid = Validation{}
|
valid = Validation{}
|
||||||
@ -524,19 +536,18 @@ func TestPointer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func TestCanSkipAlso(t *testing.T) {
|
func TestCanSkipAlso(t *testing.T) {
|
||||||
type User struct {
|
type User struct {
|
||||||
ID int
|
ID int
|
||||||
|
|
||||||
Email string `valid:"Email"`
|
Email string `valid:"Email"`
|
||||||
ReqEmail string `valid:"Required;Email"`
|
ReqEmail string `valid:"Required;Email"`
|
||||||
MatchRange int `valid:"Range(10, 20)"`
|
MatchRange int `valid:"Range(10, 20)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
u := User{
|
u := User{
|
||||||
ReqEmail: "a@a.com",
|
ReqEmail: "a@a.com",
|
||||||
Email: "",
|
Email: "",
|
||||||
MatchRange: 0,
|
MatchRange: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,4 +571,3 @@ func TestCanSkipAlso(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,7 +632,7 @@ func (b Base64) GetLimitValue() interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// just for chinese mobile phone number
|
// just for chinese mobile phone number
|
||||||
var mobilePattern = regexp.MustCompile(`^((\+86)|(86))?(1(([35][0-9])|[8][0-9]|[7][06789]|[4][579]))\d{8}$`)
|
var mobilePattern = regexp.MustCompile(`^((\+86)|(86))?(1(([35][0-9])|[8][0-9]|[7][01356789]|[4][579]))\d{8}$`)
|
||||||
|
|
||||||
// Mobile check struct
|
// Mobile check struct
|
||||||
type Mobile struct {
|
type Mobile struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user