diff --git a/Dockerfile b/Dockerfile index 581bce0..21db691 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # --- https://hub.docker.com/_/golang # --- https://github.com/microsoft/vscode-remote-try-go/blob/master/.devcontainer/Dockerfile ### ----------------------- -FROM golang:1.14.2 AS development +FROM golang:1.16.0 AS development # Avoid warnings by switching to noninteractive ENV DEBIAN_FRONTEND=noninteractive diff --git a/bool.go b/bool.go index 01214ce..61f549e 100644 --- a/bool.go +++ b/bool.go @@ -4,10 +4,20 @@ package nullable import ( "bytes" + "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Bool{} + _ runtime.ContextValidatable = &Bool{} + _ runtime.Validatable = &BoolSlice{} + _ runtime.ContextValidatable = &BoolSlice{} +) + // Bool represents a bool that may be null or not // present in json at all. type Bool struct { @@ -42,11 +52,16 @@ func (b *Bool) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (b *Bool) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (b *Bool) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // BoolSlice represents a []bool that may be null or not // present in json at all. type BoolSlice struct { @@ -70,3 +85,23 @@ func (b *BoolSlice) UnmarshalJSON(data []byte) error { b.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (b *BoolSlice) Ptr() *[]bool { + if b.Present && b.Valid { + return &b.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (b *BoolSlice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (b *BoolSlice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/docker-helper.sh b/docker-helper.sh old mode 100644 new mode 100755 diff --git a/float32.go b/float32.go index 054dddd..00becda 100644 --- a/float32.go +++ b/float32.go @@ -4,10 +4,20 @@ package nullable import ( "bytes" + "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Float32{} + _ runtime.ContextValidatable = &Float32{} + _ runtime.Validatable = &Float32Slice{} + _ runtime.ContextValidatable = &Float32Slice{} +) + // Float32 represents a float32 that may be null or not // present in json at all. type Float32 struct { @@ -42,11 +52,16 @@ func (f *Float32) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (f *Float32) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (f *Float32) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // Float32Slice represents a []float32 that may be null or not // present in json at all. type Float32Slice struct { @@ -70,3 +85,23 @@ func (f *Float32Slice) UnmarshalJSON(data []byte) error { f.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (f *Float32Slice) Ptr() *[]float32 { + if f.Present && f.Valid { + return &f.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (f *Float32Slice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (f *Float32Slice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/float64.go b/float64.go index c671896..455c23a 100644 --- a/float64.go +++ b/float64.go @@ -4,10 +4,20 @@ package nullable import ( "bytes" + "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Float64{} + _ runtime.ContextValidatable = &Float64{} + _ runtime.Validatable = &Float64Slice{} + _ runtime.ContextValidatable = &Float64Slice{} +) + // Float64 represents a float64 that may be null or not // present in json at all. type Float64 struct { @@ -42,11 +52,16 @@ func (f *Float64) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (f *Float64) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (f *Float64) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // Float64Slice represents a []float64 that may be null or not // present in json at all. type Float64Slice struct { @@ -70,3 +85,23 @@ func (f *Float64Slice) UnmarshalJSON(data []byte) error { f.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (f *Float64Slice) Ptr() *[]float64 { + if f.Present && f.Valid { + return &f.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (f *Float64Slice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (f *Float64Slice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/go.mod b/go.mod index 327c446..24e5f00 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,8 @@ module github.com/allaboutapps/nullable -go 1.14 +go 1.16 require ( - github.com/go-openapi/strfmt v0.19.11 + github.com/go-openapi/runtime v0.19.26 + github.com/go-openapi/strfmt v0.20.0 ) diff --git a/go.sum b/go.sum index ac7e43d..aef3231 100644 --- a/go.sum +++ b/go.sum @@ -1,14 +1,82 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= +github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= +github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= +github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= +github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= +github.com/go-openapi/analysis v0.19.4/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= +github.com/go-openapi/analysis v0.19.5/go.mod h1:hkEAkxagaIvIP7VTn8ygJNkd4kAYON2rCu0v0ObL0AU= +github.com/go-openapi/analysis v0.19.10/go.mod h1:qmhS3VNFxBlquFJ0RGoDtylO9y4pgTAUNE9AEEMdlJQ= +github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= +github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= +github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= +github.com/go-openapi/errors v0.19.3/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= +github.com/go-openapi/errors v0.19.6/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= github.com/go-openapi/errors v0.19.8 h1:doM+tQdZbUm9gydV9yR+iQNmztbjj7I3sW4sIcAwIzc= github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/strfmt v0.19.11 h1:0+YvbNh05rmBkgztd6zHp4OCFn7Mtu30bn46NQo2ZRw= -github.com/go-openapi/strfmt v0.19.11/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= +github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= +github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= +github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs= +github.com/go-openapi/loads v0.19.3/go.mod h1:YVfqhUCdahYwR3f3iiwQLhicVRvLlU/WO5WPaZvcvSI= +github.com/go-openapi/loads v0.19.5/go.mod h1:dswLCAdonkRufe/gSUC3gN8nTSaB9uaS2es0x5/IbjY= +github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= +github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= +github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4= +github.com/go-openapi/runtime v0.19.15/go.mod h1:dhGWCTKRXlAfGnQG0ONViOZpjfg0m2gUt9nTQPQZuoo= +github.com/go-openapi/runtime v0.19.26 h1:K/6PoVNj5WJXUnMk+VEbELeXjtBkCS1UxTDa04tdXE0= +github.com/go-openapi/runtime v0.19.26/go.mod h1:BvrQtn6iVb2QmiVXRsFAm6ZCAZBpbVKFfN6QWCp582M= +github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= +github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= +github.com/go-openapi/spec v0.19.6/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= +github.com/go-openapi/spec v0.19.8/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= +github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= +github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= +github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= +github.com/go-openapi/strfmt v0.19.2/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= +github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= +github.com/go-openapi/strfmt v0.19.4/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= +github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= +github.com/go-openapi/strfmt v0.20.0 h1:l2omNtmNbMc39IGptl9BuXBEKcZfS8zjrTsPKTiJiDM= +github.com/go-openapi/strfmt v0.20.0/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= +github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= +github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= +github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.7/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= +github.com/go-openapi/swag v0.19.9 h1:1IxuqvBUU3S2Bi4YC7tlP9SJF1gVpCvqN0T2Qof4azE= +github.com/go-openapi/swag v0.19.9/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= +github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= +github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= +github.com/go-openapi/validate v0.19.3/go.mod h1:90Vh6jjkTn+OT1Eefm0ZixWNFjhtOH7vS9k0lo6zwJo= +github.com/go-openapi/validate v0.19.10/go.mod h1:RKEZTUWDkxKQxN2jDT7ZnZi2bhZlbNMAuKvKB+IaGx8= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -37,7 +105,12 @@ github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGt github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -45,23 +118,39 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.1 h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8= +github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -73,44 +162,76 @@ github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3 github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.mongodb.org/mongo-driver v1.3.0/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= +go.mongodb.org/mongo-driver v1.3.4/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= go.mongodb.org/mongo-driver v1.4.3 h1:moga+uhicpVshTyaqY9L23E6QqwcHRUv1sqyOsoyOO8= go.mongodb.org/mongo-driver v1.4.3/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/int.go b/int.go index 4e729cb..053b93b 100644 --- a/int.go +++ b/int.go @@ -4,10 +4,20 @@ package nullable import ( "bytes" + "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Int{} + _ runtime.ContextValidatable = &Int{} + _ runtime.Validatable = &IntSlice{} + _ runtime.ContextValidatable = &IntSlice{} +) + // Int represents a int that may be null or not // present in json at all. type Int struct { @@ -42,11 +52,16 @@ func (i *Int) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (i *Int) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // IntSlice represents a []int that may be null or not // present in json at all. type IntSlice struct { @@ -70,3 +85,23 @@ func (i *IntSlice) UnmarshalJSON(data []byte) error { i.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (i *IntSlice) Ptr() *[]int { + if i.Present && i.Valid { + return &i.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (i *IntSlice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *IntSlice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/int16.go b/int16.go index 3ea3a36..d75bb83 100644 --- a/int16.go +++ b/int16.go @@ -4,10 +4,20 @@ package nullable import ( "bytes" + "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Int16{} + _ runtime.ContextValidatable = &Int16{} + _ runtime.Validatable = &Int16Slice{} + _ runtime.ContextValidatable = &Int16Slice{} +) + // Int16 represents a int16 that may be null or not // present in json at all. type Int16 struct { @@ -42,11 +52,16 @@ func (i *Int16) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (i *Int16) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int16) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // Int16Slice represents a []int16 that may be null or not // present in json at all. type Int16Slice struct { @@ -70,3 +85,23 @@ func (i *Int16Slice) UnmarshalJSON(data []byte) error { i.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (i *Int16Slice) Ptr() *[]int16 { + if i.Present && i.Valid { + return &i.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (i *Int16Slice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int16Slice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/int32.go b/int32.go index b4e42a5..9df4bb3 100644 --- a/int32.go +++ b/int32.go @@ -4,10 +4,20 @@ package nullable import ( "bytes" + "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Int32{} + _ runtime.ContextValidatable = &Int32{} + _ runtime.Validatable = &Int32Slice{} + _ runtime.ContextValidatable = &Int32Slice{} +) + // Int32 represents a int32 that may be null or not // present in json at all. type Int32 struct { @@ -42,11 +52,16 @@ func (i *Int32) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (i *Int32) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int32) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // Int32Slice represents a []int32 that may be null or not // present in json at all. type Int32Slice struct { @@ -70,3 +85,23 @@ func (i *Int32Slice) UnmarshalJSON(data []byte) error { i.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (i *Int32Slice) Ptr() *[]int32 { + if i.Present && i.Valid { + return &i.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (i *Int32Slice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int32Slice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/int64.go b/int64.go index 4eefdd1..2125fd0 100644 --- a/int64.go +++ b/int64.go @@ -4,10 +4,20 @@ package nullable import ( "bytes" + "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Int64{} + _ runtime.ContextValidatable = &Int64{} + _ runtime.Validatable = &Int64Slice{} + _ runtime.ContextValidatable = &Int64Slice{} +) + // Int64 represents a int64 that may be null or not // present in json at all. type Int64 struct { @@ -42,11 +52,16 @@ func (i *Int64) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (i *Int64) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int64) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // Int64Slice represents a []int64 that may be null or not // present in json at all. type Int64Slice struct { @@ -70,3 +85,23 @@ func (i *Int64Slice) UnmarshalJSON(data []byte) error { i.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (i *Int64Slice) Ptr() *[]int64 { + if i.Present && i.Valid { + return &i.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (i *Int64Slice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int64Slice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/scripts/modulename/modulename.go b/scripts/modulename/modulename.go deleted file mode 100644 index c4838a6..0000000 --- a/scripts/modulename/modulename.go +++ /dev/null @@ -1,32 +0,0 @@ -// +build scripts - -// This program prints the current project's module name -// It can be invoked by running go run scripts/modulename/modulename.go -package main - -import ( - "fmt" - "log" - - "allaboutapps.dev/tpa/portal-backend/internal/util" - "allaboutapps.dev/tpa/portal-backend/scripts" -) - -// https://blog.carlmjohnson.net/post/2016-11-27-how-to-use-go-generate/ - -var ( - PROJECT_ROOT = util.GetProjectRootDir() - PATH_MOD_FILE = PROJECT_ROOT + "/go.mod" -) - -// get all functions in above handler packages -// that match Get*, Put*, Post*, Patch*, Delete* -func main() { - baseModuleName, err := scripts.GetModuleName(PATH_MOD_FILE) - - if err != nil { - log.Fatal(err) - } - - fmt.Println(baseModuleName) -} diff --git a/scripts/nullable/nullable_types.gotmpl b/scripts/nullable/nullable_types.gotmpl index 81030ea..5055a62 100644 --- a/scripts/nullable/nullable_types.gotmpl +++ b/scripts/nullable/nullable_types.gotmpl @@ -4,10 +4,20 @@ package nullable import ( "bytes" + "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &{{ .NullableType }}{} + _ runtime.ContextValidatable = &{{ .NullableType }}{} + _ runtime.Validatable = &{{ .NullableType }}Slice{} + _ runtime.ContextValidatable = &{{ .NullableType }}Slice{} +) + // {{ .NullableType }} represents a {{ .Type }} that may be null or not // present in json at all. type {{ .NullableType }} struct { @@ -42,11 +52,16 @@ func ({{ .Short }} *{{ .NullableType }}) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func ({{ .Short }} *{{ .NullableType }}) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func ({{ .Short }} *{{ .NullableType }}) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // {{ .NullableType }}Slice represents a []{{ .Type }} that may be null or not // present in json at all. type {{ .NullableType }}Slice struct { @@ -70,3 +85,23 @@ func ({{ .Short }} *{{ .NullableType }}Slice) UnmarshalJSON(data []byte) error { {{ .Short }}.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func ({{ .Short }} *{{ .NullableType }}Slice) Ptr() *[]{{ .Type }} { + if {{ .Short }}.Present && {{ .Short }}.Valid { + return &{{ .Short }}.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func ({{ .Short }} *{{ .NullableType }}Slice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func ({{ .Short }} *{{ .NullableType }}Slice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/string.go b/string.go index f4261e7..76d176f 100644 --- a/string.go +++ b/string.go @@ -4,10 +4,20 @@ package nullable import ( "bytes" + "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &String{} + _ runtime.ContextValidatable = &String{} + _ runtime.Validatable = &StringSlice{} + _ runtime.ContextValidatable = &StringSlice{} +) + // String represents a string that may be null or not // present in json at all. type String struct { @@ -42,11 +52,16 @@ func (s *String) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (s *String) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (s *String) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // StringSlice represents a []string that may be null or not // present in json at all. type StringSlice struct { @@ -70,3 +85,23 @@ func (s *StringSlice) UnmarshalJSON(data []byte) error { s.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (s *StringSlice) Ptr() *[]string { + if s.Present && s.Valid { + return &s.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (s *StringSlice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (s *StringSlice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +}