go-openapi / validate

openapi toolkit validation helpers
Apache License 2.0
115 stars 53 forks source link

fix: *string(nil) not equal &string #152

Closed jiuker closed 1 year ago

jiuker commented 1 year ago

fix: *string(nil) not equal &string("")

func TestRequired(t *testing.T) {
    empty := ""
    a := struct {
        A *string
    }{
        A: &empty,
    }
    t.Log(Required("A", "a", a.A))
    t.Log(BeforeRequired("A", "a", a.A))
}
=== RUN   TestRequired
    require_test.go:14: A in a is required
    require_test.go:15: <nil>
--- PASS: TestRequired (0.00s)
PASS
youyuanwu commented 1 year ago

Can you add the test case in the test file?

jiuker commented 1 year ago

@youyuanwu I put the UT now. Reivew plz.

jiuker commented 1 year ago

@youyuanwu Looks like workflow failed. But it doesn't feel like it has anything to do with the pr I submitted.

youyuanwu commented 1 year ago

Master branch ci is working now. go version is updated as well. You can rebase.

jiuker commented 1 year ago

@youyuanwu cc

codecov[bot] commented 1 year ago

Codecov Report

Merging #152 (1621beb) into master (c9f1d67) will decrease coverage by 0.07%. The diff coverage is 80.00%.

@@            Coverage Diff             @@
##           master     #152      +/-   ##
==========================================
- Coverage   90.73%   90.66%   -0.07%     
==========================================
  Files          22       22              
  Lines        2979     2990      +11     
==========================================
+ Hits         2703     2711       +8     
- Misses        224      226       +2     
- Partials       52       53       +1     
Files Changed Coverage Δ
values.go 98.32% <80.00%> (-0.98%) :arrow_down:
jiuker commented 1 year ago

@casualjim will I do more tests for code cover?

wawaka commented 9 months ago

this should be reverted as it breaks validation completely @youyuanwu