Пример #1
0
func (f *LoginForm) Validate() error {
	validate := validation.New()

	validate.String(f.Email).NotEmpty("Email cannot be blank")
	validate.String(f.Password).NotEmpty("Password cannot be blank")

	return validate.Result()
}
Пример #2
0
func (f *SignupForm) Validate() error {
	validate := validation.New()

	validate.String(f.Email).NotEmpty("Email cannot be blank").Equals(f.EmailConfirmation, "Email didn't match email confirmation")
	validate.String(f.Password).NotEmpty("Password cannot be blank").Equals(f.PasswordConfirmation, "Password didn't match password confirmation")

	return validate.Result()
}