當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Validation.Email方法代碼示例

本文整理匯總了Golang中github.com/robfig/revel.Validation.Email方法的典型用法代碼示例。如果您正苦於以下問題:Golang Validation.Email方法的具體用法?Golang Validation.Email怎麽用?Golang Validation.Email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/robfig/revel.Validation的用法示例。


在下文中一共展示了Validation.Email方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Validate

func (regUser *RegUser) Validate(v *revel.Validation, session *mgo.Session) {
	//Check workflow:
	//see @validation.go Check(obj interface{}, checks ...Validator)
	//Validator is an interface, v.Check invoke v.Apply for each validator.
	//Further, v.Apply invoke validator.IsSatisfied with passing obj.
	//Checking result is an object of ValidationResult. The field Ok of ValidationResult
	//would be true if checking success. Otherwise, Ok would be false, and another filed
	//Error of ValidationResult would be non-nil, an ValidationError filled with error message
	//should be assigned to Error.
	v.Check(regUser.UserName,
		revel.Required{},
		revel.Match{USERNAME_REX},
		DuplicatedUserValidator{session},
	)

	//validation provide an convenient method for checking Email.
	//revel has a const for email rexgep, Email will use the rex to check email string.
	v.Email(regUser.Email)
	v.Check(regUser.Email,
		DuplicatedEmailValidator{session},
	)

	v.Check(regUser.PasswordStr,
		revel.Required{},
		revel.Match{PWD_REX},
	)
	v.Check(regUser.ConfirmPwdStr,
		revel.Required{},
		revel.Match{PWD_REX},
	)
	//pwd and comfirm_pwd should be equal
	v.Required(regUser.PasswordStr == regUser.ConfirmPwdStr).Message("The passwords do not match.")
}
開發者ID:jsli,項目名稱:cms,代碼行數:33,代碼來源:reg_user.go

示例2: Validate

func (a *Admin) Validate(v *revel.Validation) {
	v.Required(a.Username).Message("請輸入用戶名!")
	valid := v.Match(a.Username, regexp.MustCompile("^\\w*$")).Message("隻能使用字母、數字和下劃線!")
	if valid.Ok {
		if a.HasName() {
			err := &revel.ValidationError{
				Message: "該用戶名已經注冊過!",
				Key:     "a.Username",
			}
			valid.Error = err
			valid.Ok = false

			v.Errors = append(v.Errors, err)
		}
	}

	v.Required(a.Email).Message("請輸入Email")
	valid = v.Email(a.Email).Message("無效的電子郵件!")
	if valid.Ok {
		if a.HasEmail() {
			err := &revel.ValidationError{
				Message: "該郵件已經注冊過!",
				Key:     "a.Email",
			}
			valid.Error = err
			valid.Ok = false

			v.Errors = append(v.Errors, err)
		}
	}

	v.Required(a.Password).Message("請輸入密碼!")
	v.MinSize(a.Password, 3).Message("密碼最少三位!")
}
開發者ID:qmdx,項目名稱:GoCMS,代碼行數:34,代碼來源:admin.go

示例3: Validate

func (user *User) Validate(v *revel.Validation) {
	v.Required(user.Name).Message("請輸入用戶名")
	valid := v.Match(user.Name, nameRegex).Message("隻能使用字母、數字和下劃線")
	if valid.Ok {
		if user.HasName() {
			err := &revel.ValidationError{
				Message: "該用戶名已經注冊過",
				Key:     "user.Name",
			}
			valid.Error = err
			valid.Ok = false

			v.Errors = append(v.Errors, err)
		}
	}

	v.Required(user.Email).Message("請輸入Email")
	valid = v.Email(user.Email).Message("無效的電子郵件")
	if valid.Ok {
		if user.HasEmail() {
			err := &revel.ValidationError{
				Message: "該郵件已經注冊過",
				Key:     "user.Email",
			}
			valid.Error = err
			valid.Ok = false

			v.Errors = append(v.Errors, err)
		}
	}

	v.Required(user.Password).Message("請輸入密碼")
	v.MinSize(user.Password, 3).Message("密碼最少三位")
	v.Required(user.ConfirmPassword == user.Password).Message("密碼不一致")
}
開發者ID:jsli,項目名稱:gorevel,代碼行數:35,代碼來源:user.go

示例4: Validate

func (user *User) Validate(v *revel.Validation) {
	v.Required(user.Password)
	//v.MinSize(user.Password, 6)
	v.Required(user.Email)
	v.Email(user.Email)

	if user.Email == "[email protected]" && user.Password == "test" {
		user.Id = "6964943e-535a-4736-85ad-4baaa9656709"
	} else {
		v.Error("Sorry! invalid account ...")
	}
}
開發者ID:puspesh,項目名稱:cdfs,代碼行數:12,代碼來源:user.go

示例5: Validate

func (c *Credentials) Validate(v *revel.Validation) {

	v.Required(c.Email)
	v.Email(c.Email)
	v.MaxSize(c.Email, 32)
	v.MinSize(c.Email, 5)

	v.Required(c.Password)
	v.MaxSize(c.Password, 128)
	v.MinSize(c.Password, 6)

}
開發者ID:eovchinn,項目名稱:socialwhales,代碼行數:12,代碼來源:credentials.go

示例6: Validate

func (user *User) Validate(v *revel.Validation) {
	v.Required(user.Username)
	v.MinSize(user.Username, 6)
	v.Required(user.FirstName)
	v.Required(user.LastName)
	v.Required(user.Age)
	v.Range(user.Age, 16, 120)
	v.Required(user.Password)
	v.MinSize(user.Password, 6)
	v.Required(user.PasswordConfirm)
	v.Required(user.PasswordConfirm == user.Password).
		Message("The passwords do not match.")
	v.Required(user.Email)
	v.Email(user.Email)
	v.Required(user.EmailConfirm)
	v.Required(user.EmailConfirm == user.Email).
		Message("The email addresses do not match")
	v.Required(user.TermsOfUse)
}
開發者ID:huaguzi,項目名稱:revel,代碼行數:19,代碼來源:user.go

示例7: Validate

func (user *User) Validate(v *revel.Validation) {
	v.Check(user.Firstname,
		revel.Required{},
		revel.MinSize{1},
		revel.MaxSize{64},
	)

	v.Check(user.Lastname,
		revel.Required{},
		revel.MinSize{1},
		revel.MaxSize{64},
	)

	v.Check(user.Email,
		revel.Required{},
	)

	v.Email(user.Email)
}
開發者ID:stunti,項目名稱:bloggo,代碼行數:19,代碼來源:user.go

示例8: Validate

func (user *User) Validate(v *revel.Validation) {

	/*
		v.Check(user.Username,
			revel.Required{},
			revel.Range{revel.Min{4},revel.Max{15}},
			revel.Match{userRegex},
		)

		v.Check(user.Email,
			revel.Required{},
			revel.MaxSize{50},
			revel.MinSize{4},

			//revel.Match{revel.emailPattern},
		).Message("Email")

		ValidatePassword(v, user.Password).
			Key("user.Password")

		v.Check(user.Name,
			revel.Required{},
			revel.MaxSize{100},
		)
	*/

	v.Required(user.Username)
	v.MinSize(user.Username, 6).Message("Username must be at least 6 characters")

	v.Required(user.Name)
	v.MinSize(user.Name, 2).Message("Name must be at least 2 characters")

	v.Required(user.Email)
	v.Email(user.Email)
	v.MinSize(user.Email, 5)

	/*
		v.Required(user.Password)
		v.MinSize(user.Password, 8).Message("Password must be at least 8 characters")
	*/

}
開發者ID:shaheemirza,項目名稱:CAGo,代碼行數:42,代碼來源:user.go

示例9: Validation

//校驗
func (user *User) Validation(q *qbs.Qbs, v *revel.Validation) {

	v.Required(user.UserName).Message("請輸入用戶名")
	v.Required(user.Email).Message("請輸入郵箱")
	v.Required(user.Password).Message("請輸入密碼")
	valid := v.Email(user.Email).Message("郵箱格式錯誤")

	if valid.Ok {
		if user.HasEmail(q) {
			err := &revel.ValidationError{
				Message: "該郵件已經注冊過",
				Key:     "user.Email",
			}
			valid.Error = err
			valid.Ok = false

			v.Errors = append(v.Errors, err)
		}
	}

	v.Required(user.Password == user.AffirmPassword).Message("兩次密碼輸入不一致")

}
開發者ID:river-lee,項目名稱:qishare,代碼行數:24,代碼來源:user.go

示例10: ValidateLogin

func (user *User) ValidateLogin(v *revel.Validation) {
	v.Required(user.Email)
	v.Required(user.Password)
	v.Email(user.Email)
}
開發者ID:Qwait,項目名稱:revauth,代碼行數:5,代碼來源:user.go


注:本文中的github.com/robfig/revel.Validation.Email方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。