Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go lang Field validation for 'Code' failed on the 'required' tag #1311

nareshbandameedi opened this issue Mar 17, 2019 · 1 comment


None yet
1 participant
Copy link

commented Mar 17, 2019

Issue Description

Query parameters input validation is failing

Steps to reproduce

Request URL:''

Working code to debug

type ActionByRuleRequest struct {
    Code  string `json:"code" form:"code" query:"code" validate:"required,oneof=gde cse scc"`
    Name string `json:"name" form:"name" query:"name" validate:"required"` // Monitoring rule name
import (
	validator ""
func GetActionByRule(c echo.Context) error {
    // Get parameters from the query string
    req := new(model.ActionByRuleRequest)
    err := c.Bind(req);
    if  err != nil {
        error := model.Error{
            Message: err.Error(),
        responseError := &model.ResponseError{
            Status: http.StatusBadRequest,
            Code:   "INVALID_INPUT",
        responseError.Errors = append(responseError.Errors, error)
        return echo.NewHTTPError(http.StatusBadRequest, responseError)
    // Validate input
    log.Printf("[/action_by_rule] 00000000000 get req = %#v\n", req)

    v := validator.New()

    err = v.Struct(req); 

    if err == nil {
        log.Println("Input valid")
    } else {
        log.Println("Input validation failed:", err)


Key: 'ActionByRuleRequest.Code' Error:Field validation for 'Code' failed on the 'required' tag
Key: 'ActionByRuleRequest.Name' Error:Field validation for 'Name' failed on the 'required' tag

This comment has been minimized.

Copy link

commented May 16, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label May 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.