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 wuhuizuo commented Mar 26, 2020

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

@codecov
Copy link

@codecov 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
binding/default_validator_test.go Outdated Show resolved Hide resolved
binding/default_validator_test.go Outdated Show resolved Hide resolved
binding/default_validator.go Outdated Show resolved Hide resolved
@wuhuizuo wuhuizuo force-pushed the feature/array_support_for_json_bind branch from c29edbb to 023a72b Apr 13, 2020
@thinkerou thinkerou requested review from thinkerou and appleboy Oct 27, 2020
@appleboy
Copy link
Member

@appleboy appleboy commented Oct 30, 2020

@wuhuizuo Please fix the conflicts.

@wuhuizuo
Copy link
Contributor Author

@wuhuizuo wuhuizuo commented Nov 2, 2020

@wuhuizuo Please fix the conflicts.

done.

@appleboy
Copy link
Member

@appleboy 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

@thinkerou thinkerou Nov 8, 2020

SYNTAX ERROR

Copy link
Contributor Author

@wuhuizuo wuhuizuo Nov 9, 2020

sorry! it's fixed.

Copy link
Member

@thinkerou thinkerou left a comment

lgtm

@appleboy
Copy link
Member

@appleboy appleboy commented Nov 13, 2020

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

@thinkerou thinkerou commented Nov 13, 2020

@appleboy related issue: #2553

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

Successfully merging this pull request may close these issues.

None yet

3 participants