コード例 #1
0
func validateLogin(username, password string) validator.Validator {
	v := validator.New()

	v.RequiredString(username, ErrUsernameRequired)
	v.RequiredString(password, ErrPasswordRequired)

	return v
}
コード例 #2
0
func validateLogin(data *LoginData) validator.Validator {
	v := validator.New()

	v.RequiredString(data.Username, ErrUsernameRequired, "username")
	v.RequiredString(data.Password, ErrPasswordRequired, "password")

	return v
}
コード例 #3
0
func validateChangePassword(req *ChangePasswordRequest) validator.Validator {
	v := validator.New()

	v.RequiredString(req.Password, ErrPasswordRequired, "password")
	v.RequiredString(req.OldPassword, ErrOldPasswordRequired, "old_password")

	return v
}
コード例 #4
0
func validateUpdateUser(req *UpdateUserRequest) validator.Validator {
	v := validator.New()

	v.RequiredString(req.Name, ErrNameRequired, "name")
	v.RequiredString(req.Email, ErrEmailRequired, "email")

	return v
}
コード例 #5
0
func validateChangePassword(id, password, oldPassword string) validator.Validator {
	v := validator.New()

	v.RequiredString(id, ErrNameRequired)
	v.RequiredString(password, ErrPasswordRequired)
	v.RequiredString(oldPassword, ErrOldPasswordRequired)

	return v
}
コード例 #6
0
func validateUpdate(id, name, email string) validator.Validator {
	v := validator.New()

	v.RequiredString(id, ErrNameRequired)
	v.RequiredString(name, ErrNameRequired)
	v.RequiredString(email, ErrEmailRequired)

	return v
}
コード例 #7
0
func validateCreate(input *CreateInput) validator.Validator {
	v := validator.New()

	v.RequiredString(input.Username, ErrUsernameRequired)
	v.RequiredString(input.Password, ErrPasswordRequired)
	v.RequiredString(input.Name, ErrNameRequired)
	v.RequiredString(input.Email, ErrEmailRequired)
	v.Email(input.Email, ErrEmailInvalid)

	return v
}
コード例 #8
0
func validateRegister(form *RegisterForm) validator.Validator {
	v := validator.New()

	v.RequiredString(form.Username, ErrUsernameRequired)
	v.RequiredString(form.Password, ErrPasswordRequired)
	v.RequiredString(form.Name, ErrNameRequired)
	v.RequiredString(form.Email, ErrEmailRequired)
	v.Email(form.Email, ErrEmailInvalid)

	return v
}
コード例 #9
0
func validateCreateUser(req *CreateUserRequest) validator.Validator {
	v := validator.New()

	v.RequiredString(req.Username, ErrUsernameRequired, "username")
	v.RequiredString(req.Password, ErrPasswordRequired, "password")
	v.RequiredString(req.Name, ErrNameRequired, "name")
	v.RequiredString(req.Email, ErrEmailRequired, "email")
	v.Email(req.Email, ErrEmailInvalid, "email")

	return v
}
コード例 #10
0
func ValidateRegister(data *RegisterData) validator.Validator {
	v := validator.New()

	v.RequiredString(data.Username, ErrUsernameRequired, "username")
	v.RequiredString(data.Password, ErrPasswordRequired, "password")
	v.RequiredString(data.ConfirmPassword, ErrConfirmPasswordRequired, "confirm_password")
	v.Confirm(data.Password, data.ConfirmPassword, ErrPasswordMisMatch, "password")
	v.RequiredString(data.Name, ErrNameRequired, "name")
	v.RequiredString(data.Email, ErrEmailRequired, "email")
	v.Email(data.Email, ErrEmailInvalid, "email")

	return v
}