diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..65b45f1 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +github: markbates +patreon: buffalo diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..68804c1 --- /dev/null +++ b/.github/workflows/tests.yml @@ -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 ./... + + diff --git a/.gitignore b/.gitignore index 6d1602b..56572b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.log +cover.out .DS_Store doc tmp @@ -27,5 +28,3 @@ generated/ bin/* gin-bin .idea/ -go.mod -go.sum diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6d5fadd --- /dev/null +++ b/LICENSE @@ -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. diff --git a/Makefile b/Makefile index e0e2f3b..17db3a6 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index f4e447d..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,59 +0,0 @@ -variables: - GOBIN: "$(GOPATH)/bin" # Go binaries path - GOPATH: "$(system.defaultWorkingDirectory)/gopath" # Go workspace path - modulePath: "$(GOPATH)/src/github.com/$(build.repository.name)" # Path to the module"s code - -jobs: -- job: Windows - pool: - vmImage: "vs2017-win2016" - strategy: - matrix: - go 1.9: - go_version: "1.9" - go 1.10: - go_version: "1.10" - # go 1.11 (on): - # go_version: "1.11" - # GO111MODULE: "on" - go 1.11 (off): - go_version: "1.11" - GO111MODULE: "off" - steps: - - template: azure-tests.yml - -- job: macOS - pool: - vmImage: "macOS-10.13" - strategy: - matrix: - go 1.9: - go_version: "1.9" - go 1.10: - go_version: "1.10" - # go 1.11 (on): - # go_version: "1.11" - # GO111MODULE: "on" - go 1.11 (off): - go_version: "1.11" - GO111MODULE: "off" - steps: - - template: azure-tests.yml - -- job: Linux - pool: - vmImage: "ubuntu-16.04" - strategy: - matrix: - go 1.9: - go_version: "1.9" - go 1.10: - go_version: "1.10" - # go 1.11 (on): - # go_version: "1.11" - # GO111MODULE: "on" - go 1.11 (off): - go_version: "1.11" - GO111MODULE: "off" - steps: - - template: azure-tests.yml diff --git a/azure-tests.yml b/azure-tests.yml deleted file mode 100644 index eea5822..0000000 --- a/azure-tests.yml +++ /dev/null @@ -1,19 +0,0 @@ -steps: - - task: GoTool@0 - inputs: - version: $(go_version) - - task: Bash@3 - inputs: - targetType: inline - script: | - mkdir -p "$(GOBIN)" - mkdir -p "$(GOPATH)/pkg" - mkdir -p "$(modulePath)" - shopt -s extglob - mv !(gopath) "$(modulePath)" - displayName: "Setup Go Workspace" - - script: | - go get -t -v ./... - go test -race ./... - workingDirectory: "$(modulePath)" - displayName: "Tests" diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..37fc6fb --- /dev/null +++ b/go.mod @@ -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 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e992581 --- /dev/null +++ b/go.sum @@ -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= diff --git a/validate_test.go b/validate_test.go index 094ba4e..14e57ff 100644 --- a/validate_test.go +++ b/validate_test.go @@ -1,10 +1,9 @@ -package validate_test +package validate import ( "encoding/xml" "testing" - . "github.com/gobuffalo/validate" "github.com/stretchr/testify/require" ) diff --git a/validators/bytes_are_present.go b/validators/bytes_are_present.go index 3e93d7f..63b7fe1 100644 --- a/validators/bytes_are_present.go +++ b/validators/bytes_are_present.go @@ -3,7 +3,7 @@ package validators import ( "fmt" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type BytesArePresent struct { diff --git a/validators/bytes_are_present_test.go b/validators/bytes_are_present_test.go index ae77e20..9244e83 100644 --- a/validators/bytes_are_present_test.go +++ b/validators/bytes_are_present_test.go @@ -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" ) diff --git a/validators/common.go b/validators/common.go index edd5441..229088e 100644 --- a/validators/common.go +++ b/validators/common.go @@ -1,9 +1,7 @@ package validators import ( - "strings" - - "github.com/serenize/snaker" + "github.com/gobuffalo/flect" ) var CustomKeys = map[string]string{} @@ -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) } diff --git a/validators/common_test.go b/validators/common_test.go index e0734d2..f1f7601 100644 --- a/validators/common_test.go +++ b/validators/common_test.go @@ -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" ) diff --git a/validators/email_is_present.go b/validators/email_is_present.go index bfc0ee5..a387a6e 100644 --- a/validators/email_is_present.go +++ b/validators/email_is_present.go @@ -5,7 +5,7 @@ import ( "regexp" "strings" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) var rxEmail *regexp.Regexp diff --git a/validators/email_is_present_test.go b/validators/email_is_present_test.go index 470ade3..50e1584 100644 --- a/validators/email_is_present_test.go +++ b/validators/email_is_present_test.go @@ -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" ) diff --git a/validators/func_validator.go b/validators/func_validator.go index 6467049..fdbcaa5 100644 --- a/validators/func_validator.go +++ b/validators/func_validator.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type FuncValidator struct { diff --git a/validators/func_validator_test.go b/validators/func_validator_test.go index 4920e33..3f8be3d 100644 --- a/validators/func_validator_test.go +++ b/validators/func_validator_test.go @@ -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", @@ -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 { diff --git a/validators/int_array_is_present.go b/validators/int_array_is_present.go index 1470544..2ccea23 100644 --- a/validators/int_array_is_present.go +++ b/validators/int_array_is_present.go @@ -3,7 +3,7 @@ package validators import ( "fmt" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type IntArrayIsPresent struct { diff --git a/validators/int_array_is_present_test.go b/validators/int_array_is_present_test.go index 86ef646..58ecbe9 100644 --- a/validators/int_array_is_present_test.go +++ b/validators/int_array_is_present_test.go @@ -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" ) diff --git a/validators/int_is_greater_than.go b/validators/int_is_greater_than.go index 394f019..aad7b55 100644 --- a/validators/int_is_greater_than.go +++ b/validators/int_is_greater_than.go @@ -3,7 +3,7 @@ package validators import ( "fmt" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type IntIsGreaterThan struct { diff --git a/validators/int_is_greater_than_test.go b/validators/int_is_greater_than_test.go index 8bb2b18..8d8a5a7 100644 --- a/validators/int_is_greater_than_test.go +++ b/validators/int_is_greater_than_test.go @@ -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" ) diff --git a/validators/int_is_less_than.go b/validators/int_is_less_than.go index 30da176..644d495 100644 --- a/validators/int_is_less_than.go +++ b/validators/int_is_less_than.go @@ -3,7 +3,7 @@ package validators import ( "fmt" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type IntIsLessThan struct { diff --git a/validators/int_is_less_than_test.go b/validators/int_is_less_than_test.go index d280db6..5631168 100644 --- a/validators/int_is_less_than_test.go +++ b/validators/int_is_less_than_test.go @@ -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" ) diff --git a/validators/int_is_present.go b/validators/int_is_present.go index 2c7fd7c..d59e829 100644 --- a/validators/int_is_present.go +++ b/validators/int_is_present.go @@ -3,7 +3,7 @@ package validators import ( "fmt" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type IntIsPresent struct { diff --git a/validators/int_is_present_test.go b/validators/int_is_present_test.go index fe3d20b..99f5265 100644 --- a/validators/int_is_present_test.go +++ b/validators/int_is_present_test.go @@ -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" ) diff --git a/validators/ints_are_equal.go b/validators/ints_are_equal.go index 6b2a49d..6512e38 100644 --- a/validators/ints_are_equal.go +++ b/validators/ints_are_equal.go @@ -3,7 +3,7 @@ package validators import ( "fmt" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) // IntsAreEqual is a validator that will compare two integers and add diff --git a/validators/ints_are_equal_test.go b/validators/ints_are_equal_test.go index b15767c..df21eb4 100644 --- a/validators/ints_are_equal_test.go +++ b/validators/ints_are_equal_test.go @@ -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" ) diff --git a/validators/ints_are_not_equal.go b/validators/ints_are_not_equal.go index a0bae2e..1efc851 100644 --- a/validators/ints_are_not_equal.go +++ b/validators/ints_are_not_equal.go @@ -3,7 +3,7 @@ package validators import ( "fmt" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) // IntsAreNotEqual is a validator that compares two integers and will add diff --git a/validators/ints_are_not_equal_test.go b/validators/ints_are_not_equal_test.go index aa30a8f..2346bf1 100644 --- a/validators/ints_are_not_equal_test.go +++ b/validators/ints_are_not_equal_test.go @@ -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" ) diff --git a/validators/regex_match.go b/validators/regex_match.go index e2e170f..12c3f55 100644 --- a/validators/regex_match.go +++ b/validators/regex_match.go @@ -4,7 +4,7 @@ import ( "fmt" "regexp" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) // RegexMatch specifies the properties needed by the validation. diff --git a/validators/regex_match_test.go b/validators/regex_match_test.go index dfb2cb6..7469c1b 100644 --- a/validators/regex_match_test.go +++ b/validators/regex_match_test.go @@ -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" ) diff --git a/validators/string_inclusion.go b/validators/string_inclusion.go index 7350cb0..4e93853 100644 --- a/validators/string_inclusion.go +++ b/validators/string_inclusion.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type StringInclusion struct { diff --git a/validators/string_inclusion_test.go b/validators/string_inclusion_test.go index 7951a6b..35301c7 100644 --- a/validators/string_inclusion_test.go +++ b/validators/string_inclusion_test.go @@ -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" ) diff --git a/validators/string_is_present.go b/validators/string_is_present.go index ad6f5dd..f5c0b0c 100644 --- a/validators/string_is_present.go +++ b/validators/string_is_present.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type StringIsPresent struct { diff --git a/validators/string_is_present_test.go b/validators/string_is_present_test.go index eddfc30..66948f5 100644 --- a/validators/string_is_present_test.go +++ b/validators/string_is_present_test.go @@ -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" ) diff --git a/validators/string_length_in_range.go b/validators/string_length_in_range.go index aa4f61e..b0eb8a5 100644 --- a/validators/string_length_in_range.go +++ b/validators/string_length_in_range.go @@ -4,7 +4,7 @@ import ( "fmt" "unicode/utf8" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type StringLengthInRange struct { diff --git a/validators/string_length_in_range_test.go b/validators/string_length_in_range_test.go index bc798c0..478e0f9 100644 --- a/validators/string_length_in_range_test.go +++ b/validators/string_length_in_range_test.go @@ -1,11 +1,10 @@ -package validators_test +package validators import ( "fmt" "testing" - "github.com/gobuffalo/validate" - . "github.com/gobuffalo/validate/validators" + "github.com/gobuffalo/validate/v3" "github.com/stretchr/testify/require" ) diff --git a/validators/strings_match.go b/validators/strings_match.go index be5245b..6372b20 100644 --- a/validators/strings_match.go +++ b/validators/strings_match.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type StringsMatch struct { diff --git a/validators/strings_match_test.go b/validators/strings_match_test.go index 68f8004..e2b226d 100644 --- a/validators/strings_match_test.go +++ b/validators/strings_match_test.go @@ -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" ) @@ -22,13 +21,13 @@ func Test_StringsMatch_IsValid(t *testing.T) { } for _, test_case := range cases { - v := validators.StringsMatch{Name: "strings", Field: test_case.str1, Field2: test_case.str2} + v := StringsMatch{Name: "strings", Field: test_case.str1, Field2: test_case.str2} errors := validate.NewErrors() v.IsValid(errors) r.Equal(test_case.expected, !errors.HasAny(), "Str1: %s, Str2: %s", test_case.str1, test_case.str2) } - v := validators.StringsMatch{Name: "strings", Field: "test_fail", Field2: "test", Message: "String doesn't match."} + v := StringsMatch{Name: "strings", Field: "test_fail", Field2: "test", Message: "String doesn't match."} errors := validate.NewErrors() v.IsValid(errors) r.Equal(errors.Count(), 1) @@ -39,7 +38,7 @@ func Test_StringsMatch_IsValid(t *testing.T) { func BenchmarkStringsMatch_IsValid_Valid(b *testing.B) { errors := validate.NewErrors() for i := 0; i <= b.N; i++ { - v := validators.StringsMatch{Name: "strings", Field: " Some string ", Field2: " Some string "} + v := StringsMatch{Name: "strings", Field: " Some string ", Field2: " Some string "} v.IsValid(errors) } } @@ -47,7 +46,7 @@ func BenchmarkStringsMatch_IsValid_Valid(b *testing.B) { func BenchmarkStringsMatch_IsValid_InValid(b *testing.B) { errors := validate.NewErrors() for i := 0; i <= b.N; i++ { - v := validators.StringsMatch{Name: "strings", Field: " Some string ", Field2: " Some string failure"} + v := StringsMatch{Name: "strings", Field: " Some string ", Field2: " Some string failure"} v.IsValid(errors) } } diff --git a/validators/time_after_time.go b/validators/time_after_time.go index d6c169d..f6ad527 100644 --- a/validators/time_after_time.go +++ b/validators/time_after_time.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type TimeAfterTime struct { @@ -21,7 +21,6 @@ func (v *TimeAfterTime) IsValid(errors *validate.Errors) { return } - if len(v.Message) > 0 { errors.Add(GenerateKey(v.FirstName), v.Message) return diff --git a/validators/time_after_time_test.go b/validators/time_after_time_test.go index 13c8717..29f658e 100644 --- a/validators/time_after_time_test.go +++ b/validators/time_after_time_test.go @@ -1,11 +1,10 @@ -package validators_test +package validators import ( "testing" "time" - "github.com/gobuffalo/validate" - . "github.com/gobuffalo/validate/validators" + "github.com/gobuffalo/validate/v3" "github.com/stretchr/testify/require" ) diff --git a/validators/time_is_before_time.go b/validators/time_is_before_time.go index f90e6a0..5ef0d72 100644 --- a/validators/time_is_before_time.go +++ b/validators/time_is_before_time.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type TimeIsBeforeTime struct { diff --git a/validators/time_is_before_time_test.go b/validators/time_is_before_time_test.go index a835ada..1b6fee0 100644 --- a/validators/time_is_before_time_test.go +++ b/validators/time_is_before_time_test.go @@ -1,11 +1,10 @@ -package validators_test +package validators import ( "testing" "time" - "github.com/gobuffalo/validate" - . "github.com/gobuffalo/validate/validators" + "github.com/gobuffalo/validate/v3" "github.com/stretchr/testify/require" ) diff --git a/validators/time_is_present.go b/validators/time_is_present.go index 993186e..37f0675 100644 --- a/validators/time_is_present.go +++ b/validators/time_is_present.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type TimeIsPresent struct { diff --git a/validators/time_is_present_test.go b/validators/time_is_present_test.go index cc4d8b2..2bc067d 100644 --- a/validators/time_is_present_test.go +++ b/validators/time_is_present_test.go @@ -1,11 +1,10 @@ -package validators_test +package validators import ( "testing" "time" - "github.com/gobuffalo/validate" - . "github.com/gobuffalo/validate/validators" + "github.com/gobuffalo/validate/v3" "github.com/stretchr/testify/require" ) diff --git a/validators/url_is_present.go b/validators/url_is_present.go index 50df35c..36650a4 100644 --- a/validators/url_is_present.go +++ b/validators/url_is_present.go @@ -4,7 +4,7 @@ import ( "fmt" "net/url" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" ) type URLIsPresent struct { diff --git a/validators/url_is_present_test.go b/validators/url_is_present_test.go index f6273f7..0446595 100644 --- a/validators/url_is_present_test.go +++ b/validators/url_is_present_test.go @@ -3,7 +3,7 @@ package validators import ( "testing" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" "github.com/stretchr/testify/require" ) diff --git a/validators/uuid_is_present.go b/validators/uuid_is_present.go index 25575a5..a5c343c 100644 --- a/validators/uuid_is_present.go +++ b/validators/uuid_is_present.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/gobuffalo/validate" + "github.com/gobuffalo/validate/v3" "github.com/gofrs/uuid" ) diff --git a/validators/uuid_is_present_test.go b/validators/uuid_is_present_test.go index 6eb838c..0ae62e1 100644 --- a/validators/uuid_is_present_test.go +++ b/validators/uuid_is_present_test.go @@ -1,11 +1,10 @@ -package validators_test +package validators import ( "testing" - "github.com/gobuffalo/validate" - . "github.com/gobuffalo/validate/validators" - uuid "github.com/gofrs/uuid" + "github.com/gobuffalo/validate/v3" + "github.com/gofrs/uuid" "github.com/stretchr/testify/require" ) diff --git a/version.go b/version.go deleted file mode 100644 index 5fb5d75..0000000 --- a/version.go +++ /dev/null @@ -1,4 +0,0 @@ -package validate - -// Version of validate -const Version = "v0.0.1"