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

Support binding for slice/array obj [Rewrite] #2302

Merged

Conversation

wuhuizuo
Copy link
Contributor

@wuhuizuo wuhuizuo commented Mar 26, 2020

support usage followed:

type StructExample struct {
    A string `json:"a" form:"a" binding"required,max=16"`
}

func exampleHandler(c *gin.Context) {
    var data []StructExample

    if c.Bind(&data) != nil {
        return
    }
    c.JSON(http.StatusOK, data)
}

this pull is rewritten for https://github.com/gin-gonic/gin/pull/2194, avoid to change the validator interface

@wuhuizuo
Copy link
Contributor Author

wuhuizuo commented Mar 26, 2020

@thinkerou @appleboy I have rewritten for review issues in #2194

@codecov
Copy link

codecov bot commented Mar 26, 2020

Codecov Report

Merging #2302 (d2db51d) into master (a573ec6) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2302      +/-   ##
==========================================
+ Coverage   98.47%   98.49%   +0.01%     
==========================================
  Files          41       41              
  Lines        1973     1989      +16     
==========================================
+ Hits         1943     1959      +16     
  Misses         17       17              
  Partials       13       13              
Impacted Files Coverage Δ
binding/binding.go 100.00% <ø> (ø)
binding/default_validator.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a573ec6...d2db51d. Read the comment docs.

@appleboy appleboy added this to the 1.7 milestone Mar 26, 2020
@wuhuizuo wuhuizuo force-pushed the feature/array_support_for_json_bind branch from c29edbb to 023a72b Compare April 13, 2020 04:38
appleboy
appleboy previously approved these changes Oct 30, 2020
@appleboy
Copy link
Member

@wuhuizuo Please fix the conflicts.

@wuhuizuo
Copy link
Contributor Author

wuhuizuo commented Nov 2, 2020

@wuhuizuo Please fix the conflicts.

done.

@appleboy
Copy link
Member

appleboy commented Nov 3, 2020

@@ -1181,6 +1195,21 @@ func testBodyBinding(t *testing.T, b Binding, name, path, badPath, body, badBody
assert.Error(t, err)
}

feature/array_support_for_json_bind
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SYNTAX ERROR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry! it's fixed.

Copy link
Member

@thinkerou thinkerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@appleboy
Copy link
Member

LGTM but build fail in go master version. See the report: https://travis-ci.org/github/gin-gonic/gin/jobs/742947069

@thinkerou
Copy link
Member

@appleboy related issue: #2553

@appleboy appleboy merged commit 4bfae4c into gin-gonic:master Jan 3, 2021
@wuhuizuo wuhuizuo deleted the feature/array_support_for_json_bind branch January 18, 2021 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants