Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
appleboy merged 11 commits into
gin-gonic:masterfrom
wuhuizuo:feature/array_support_for_json_bind
Jan 3, 2021
Merged

Support binding for slice/array obj [Rewrite]#2302
appleboy merged 11 commits into
gin-gonic:masterfrom
wuhuizuo:feature/array_support_for_json_bind

Conversation

@wuhuizuo

@wuhuizuo wuhuizuo commented Mar 26, 2020

Copy link
Copy Markdown
Contributor

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

wuhuizuo commented Mar 26, 2020

Copy link
Copy Markdown
Contributor Author

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

@codecov

codecov Bot commented Mar 26, 2020

Copy link
Copy Markdown

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
Comment thread binding/default_validator_test.go Outdated
Comment thread binding/default_validator_test.go Outdated
Comment thread binding/default_validator.go Outdated
@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
Copy Markdown
Member

@wuhuizuo Please fix the conflicts.

@wuhuizuo

wuhuizuo commented Nov 2, 2020

Copy link
Copy Markdown
Contributor Author

@wuhuizuo Please fix the conflicts.

done.

@appleboy

appleboy commented Nov 3, 2020

Copy link
Copy Markdown
Member

Comment thread binding/binding_test.go Outdated
assert.Error(t, err)
}

feature/array_support_for_json_bind

Copy link
Copy Markdown
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
Copy Markdown
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.

@thinkerou thinkerou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@appleboy

Copy link
Copy Markdown
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
Copy Markdown
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.

3 participants