Skip to content

Commit

Permalink
Merge pull request #17 from gobuffalo/v3-mod
Browse files Browse the repository at this point in the history
v3 - Adds go.mod support and reduces dependencies.
  • Loading branch information
markbates authored Jan 15, 2020
2 parents 2ada686 + 3cf5891 commit 87235c9
Show file tree
Hide file tree
Showing 51 changed files with 151 additions and 229 deletions.
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: markbates
patreon: buffalo
22 changes: 22 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Tests
on: [push]
jobs:

tests-on:
name: ${{matrix.go-version}} ${{matrix.os}}
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.12.x, 1.13.x]
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout Code
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Test
run: |
go mod tidy -v
go test -race ./...
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.log
cover.out
.DS_Store
doc
tmp
Expand Down Expand Up @@ -27,5 +28,3 @@ generated/
bin/*
gin-bin
.idea/
go.mod
go.sum
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 Mark Bates

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
59 changes: 6 additions & 53 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,55 +1,8 @@
TAGS ?= "sqlite"
GO_BIN ?= go

install:
packr
$(GO_BIN) install -tags ${TAGS} -v .
make tidy

tidy:
ifeq ($(GO111MODULE),on)
$(GO_BIN) mod tidy
else
echo skipping go mod tidy
endif

deps:
$(GO_BIN) get github.com/gobuffalo/release
$(GO_BIN) get github.com/gobuffalo/packr/packr
$(GO_BIN) get -tags ${TAGS} -t ./...
make tidy

build:
packr
$(GO_BIN) build -v .
make tidy

test:
packr
$(GO_BIN) test -tags ${TAGS} ./...
make tidy

ci-test:
$(GO_BIN) test -tags ${TAGS} -race ./...
make tidy

lint:
gometalinter --vendor ./... --deadline=1m --skip=internal
make tidy

update:
$(GO_BIN) get -u -tags ${TAGS}
make tidy
packr
make test
make install
make tidy

release-test:
$(GO_BIN) test -tags ${TAGS} -race ./...
make tidy
go test -failfast -short -cover ./...
go mod tidy -v

release:
make tidy
release -y -f version.go
make tidy
cov:
go test -short -coverprofile cover.out ./...
go tool cover -html cover.out
go mod tidy -v
59 changes: 0 additions & 59 deletions azure-pipelines.yml

This file was deleted.

19 changes: 0 additions & 19 deletions azure-tests.yml

This file was deleted.

10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/gobuffalo/validate/v3

go 1.13

require (
github.com/gobuffalo/flect v0.2.0
github.com/gofrs/uuid v3.2.0+incompatible
github.com/stretchr/testify v1.4.0
gopkg.in/yaml.v2 v2.2.4 // indirect
)
20 changes: 20 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
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/gobuffalo/flect v0.2.0 h1:EWCvMGGxOjsgwlWaP+f4+Hh6yrrte7JeFL2S6b+0hdM=
github.com/gobuffalo/flect v0.2.0/go.mod h1:W3K3X9ksuZfir8f/LrfVtWmCDQFfayuylOJ7sz/Fj80=
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
3 changes: 1 addition & 2 deletions validate_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package validate_test
package validate

import (
"encoding/xml"
"testing"

. "github.com/gobuffalo/validate"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion validators/bytes_are_present.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package validators
import (
"fmt"

"github.com/gobuffalo/validate"
"github.com/gobuffalo/validate/v3"
)

type BytesArePresent struct {
Expand Down
5 changes: 2 additions & 3 deletions validators/bytes_are_present_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package validators_test
package validators

import (
"testing"

"github.com/gobuffalo/validate"
. "github.com/gobuffalo/validate/validators"
"github.com/gobuffalo/validate/v3"
"github.com/stretchr/testify/require"
)

Expand Down
9 changes: 2 additions & 7 deletions validators/common.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package validators

import (
"strings"

"github.com/serenize/snaker"
"github.com/gobuffalo/flect"
)

var CustomKeys = map[string]string{}
Expand All @@ -13,8 +11,5 @@ func GenerateKey(s string) string {
if key != "" {
return key
}
key = strings.Replace(s, " ", "", -1)
key = strings.Replace(key, "-", "", -1)
key = snaker.CamelToSnake(key)
return key
return flect.Underscore(s)
}
2 changes: 1 addition & 1 deletion validators/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package validators_test
import (
"testing"

"github.com/gobuffalo/validate/validators"
"github.com/gobuffalo/validate/v3/validators"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion validators/email_is_present.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"strings"

"github.com/gobuffalo/validate"
"github.com/gobuffalo/validate/v3"
)

var rxEmail *regexp.Regexp
Expand Down
5 changes: 2 additions & 3 deletions validators/email_is_present_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package validators_test
package validators

import (
"testing"

"github.com/gobuffalo/validate"
. "github.com/gobuffalo/validate/validators"
"github.com/gobuffalo/validate/v3"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion validators/func_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/gobuffalo/validate"
"github.com/gobuffalo/validate/v3"
)

type FuncValidator struct {
Expand Down
9 changes: 4 additions & 5 deletions validators/func_validator_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package validators_test
package validators

import (
"testing"

"github.com/gobuffalo/validate"
"github.com/gobuffalo/validate/validators"
"github.com/gobuffalo/validate/v3"
"github.com/stretchr/testify/require"
)

func Test_FuncValidator(t *testing.T) {
r := require.New(t)

fv := &validators.FuncValidator{
fv := &FuncValidator{
Name: "Name",
Field: "Field",
Message: "%s is an invalid name",
Expand All @@ -29,7 +28,7 @@ func Test_FuncValidator(t *testing.T) {
func Test_FuncValidatorNoName(t *testing.T) {
r := require.New(t)

fv := &validators.FuncValidator{
fv := &FuncValidator{
Field: "Name",
Message: "%s is invalid",
Fn: func() bool {
Expand Down
2 changes: 1 addition & 1 deletion validators/int_array_is_present.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package validators
import (
"fmt"

"github.com/gobuffalo/validate"
"github.com/gobuffalo/validate/v3"
)

type IntArrayIsPresent struct {
Expand Down
5 changes: 2 additions & 3 deletions validators/int_array_is_present_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package validators_test
package validators

import (
"testing"

"github.com/gobuffalo/validate"
. "github.com/gobuffalo/validate/validators"
"github.com/gobuffalo/validate/v3"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion validators/int_is_greater_than.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package validators
import (
"fmt"

"github.com/gobuffalo/validate"
"github.com/gobuffalo/validate/v3"
)

type IntIsGreaterThan struct {
Expand Down
Loading

0 comments on commit 87235c9

Please sign in to comment.