Skip to content

Commit e6da236

Browse files
committed
refactor package structure to flat
1 parent 82fd27f commit e6da236

19 files changed

+1211
-1287
lines changed

.drone.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ build:
2020
- go get -u github.com/go-openapi/loads
2121
- go get -u github.com/go-openapi/strfmt
2222
- go get -u github.com/go-openapi/runtime
23-
- ./hack/build-drone.sh
23+
- go test -race
24+
- go test -v -cover -coverprofile=coverage.out -covermode=count
2425

2526
notify:
2627
slack:

validation/formats.go renamed to formats.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package validation
15+
package validate
1616

1717
import (
1818
"reflect"
1919

2020
"github.com/go-openapi/spec"
2121
"github.com/go-openapi/strfmt"
22-
validate "github.com/go-openapi/validate/validator"
2322
)
2423

2524
type formatValidator struct {
@@ -59,7 +58,7 @@ func (f *formatValidator) Applies(source interface{}, kind reflect.Kind) bool {
5958
func (f *formatValidator) Validate(val interface{}) *Result {
6059
result := new(Result)
6160

62-
if err := validate.FormatOf(f.Path, f.In, f.Format, val.(string), f.KnownFormats); err != nil {
61+
if err := FormatOf(f.Path, f.In, f.Format, val.(string), f.KnownFormats); err != nil {
6362
result.AddErrors(err)
6463
}
6564

hack/build-drone.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

validation/items_validator_test.go renamed to items_validator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package validation
15+
package validate
1616

1717
import (
1818
"encoding/json"

validation/object_validator.go renamed to object_validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package validation
15+
package validate
1616

1717
import (
1818
"reflect"

validation/parameter_validator_test.go renamed to parameter_validator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package validation
15+
package validate
1616

1717
import (
1818
"reflect"

validation/result.go renamed to result.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package validation
15+
package validate
1616

1717
import "github.com/go-openapi/errors"
1818

@@ -52,6 +52,7 @@ func (r *Result) Inc() {
5252
r.MatchCount++
5353
}
5454

55+
// AsError renders this result as an error interface
5556
func (r *Result) AsError() error {
5657
if r.IsValid() {
5758
return nil

validation/schema.go renamed to schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package validation
15+
package validate
1616

1717
import (
1818
"reflect"

validation/schema_props.go renamed to schema_props.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package validation
15+
package validate
1616

1717
import (
1818
"reflect"

validation/slice_validator.go renamed to slice_validator.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package validation
15+
package validate
1616

1717
import (
1818
"fmt"
@@ -21,7 +21,6 @@ import (
2121
"github.com/go-openapi/errors"
2222
"github.com/go-openapi/spec"
2323
"github.com/go-openapi/strfmt"
24-
validate "github.com/go-openapi/validate/validator"
2524
)
2625

2726
type schemaSliceValidator struct {
@@ -85,17 +84,17 @@ func (s *schemaSliceValidator) Validate(data interface{}) *Result {
8584
}
8685

8786
if s.MinItems != nil {
88-
if err := validate.MinItems(s.Path, s.In, int64(size), *s.MinItems); err != nil {
87+
if err := MinItems(s.Path, s.In, int64(size), *s.MinItems); err != nil {
8988
result.AddErrors(err)
9089
}
9190
}
9291
if s.MaxItems != nil {
93-
if err := validate.MaxItems(s.Path, s.In, int64(size), *s.MaxItems); err != nil {
92+
if err := MaxItems(s.Path, s.In, int64(size), *s.MaxItems); err != nil {
9493
result.AddErrors(err)
9594
}
9695
}
9796
if s.UniqueItems {
98-
if err := validate.UniqueItems(s.Path, s.In, val.Interface()); err != nil {
97+
if err := UniqueItems(s.Path, s.In, val.Interface()); err != nil {
9998
result.AddErrors(err)
10099
}
101100
}

0 commit comments

Comments
 (0)