Пример #1
0
// 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
// 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()
}
Пример #3
0
// Validate validates the Tweet struct
func (t *Tweet) Validate() error {
	return govalidator.NewMulti(govalidator.Date(t.CreatedAt),
		govalidator.Min(float64(t.ProfileID), 1.000000),
		govalidator.MinLength(t.Body, 1)).Validate()
}