示例#1
0
文件: profile.go 项目: Zenithar/gene
// Validate validates the Profile struct
func (p *Profile) Validate() error {
	return govalidator.NewMulti(govalidator.Date(p.CreatedAt),
		govalidator.MaxLength(p.AvatarURL, 2000),
		govalidator.MaxLength(p.Description, 160),
		govalidator.MaxLength(p.LinkColor, 6),
		govalidator.MaxLength(p.Location, 30),
		govalidator.MaxLength(p.ScreenName, 20),
		govalidator.MaxLength(p.URL, 100),
		govalidator.Min(float64(p.ID), 1.000000),
		govalidator.MinLength(p.ScreenName, 4)).Validate()
}
示例#2
0
文件: account.go 项目: Zenithar/gene
// Validate validates the Account struct
func (a *Account) Validate() error {
	return govalidator.NewMulti(govalidator.Date(a.CreatedAt),
		govalidator.MaxLength(a.Salt, 255),
		govalidator.Min(float64(a.ID), 1.000000),
		govalidator.Min(float64(a.ProfileID), 1.000000),
		govalidator.MinLength(a.Password, 6),
		govalidator.MinLength(a.URL, 6),
		govalidator.OneOf(a.EmailStatusConstant, []string{
			AccountEmailStatusConstant.Verified,
			AccountEmailStatusConstant.NotVerified,
		}),
		govalidator.OneOf(a.PasswordStatusConstant, []string{
			AccountPasswordStatusConstant.Valid,
			AccountPasswordStatusConstant.NeedsReset,
			AccountPasswordStatusConstant.Generated,
		}),
		govalidator.OneOf(a.StatusConstant, []string{
			AccountStatusConstant.Registered,
			AccountStatusConstant.Unregistered,
			AccountStatusConstant.NeedsManualVerification,
		})).Validate()
}