Skip to content

Commit

Permalink
convert to go modules
Browse files Browse the repository at this point in the history
  • Loading branch information
deankarn committed Nov 11, 2019
1 parent cd1bd58 commit 7e57ca0
Show file tree
Hide file tree
Showing 34 changed files with 114 additions and 137 deletions.
29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
language: go
go:
- 1.13.4
- tip
matrix:
allow_failures:
- go: tip

notifications:
email:
recipients: dean.karn@gmail.com
on_success: change
on_failure: always

before_install:
- go install github.com/mattn/goveralls
- mkdir -p $GOPATH/src/gopkg.in
- ln -s $GOPATH/src/github.com/$TRAVIS_REPO_SLUG $GOPATH/src/gopkg.in/validator.v9

# Only clone the most recent commit.
git:
depth: 1

script:
- go test -v -race -covermode=atomic -coverprofile=coverage.coverprofile ./...

after_success: |
[ $TRAVIS_GO_VERSION = 1.13.4 ] &&
goveralls -coverprofile=coverage.coverprofile -service travis-ci -repotoken $COVERALLS_TOKEN
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
GOCMD=go
GOCMD=GO111MODULE=on go

linters-install:
@golangci-lint --version >/dev/null 2>&1 || { \
echo "installing linting tools..."; \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.19.1; \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.21.0; \
}

lint: linters-install
golangci-lint run
$(PWD)/bin/golangci-lint run

test:
$(GOCMD) test -cover -race ./...
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package validator
================
<img align="right" src="https://raw.githubusercontent.com/go-playground/validator/v9/logo.png">[![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Project status](https://img.shields.io/badge/version-9.30.0-green.svg)
[![Build Status](https://semaphoreci.com/api/v1/joeybloggs/validator/branches/v9/badge.svg)](https://semaphoreci.com/joeybloggs/validator)
[![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=v9&service=github)](https://coveralls.io/github/go-playground/validator?branch=v9)
![Project status](https://img.shields.io/badge/version-10.0.0-green.svg)
[![Build Status](https://travis-ci.org/go-playground/validator.svg?branch=master)](https://travis-ci.org/go-playground/validator)
[![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-playground/validator?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator)
[![GoDoc](https://godoc.org/gopkg.in/go-playground/validator.v9?status.svg)](https://godoc.org/gopkg.in/go-playground/validator.v9)
[![GoDoc](https://godoc.org/github.com/go-playground/validator?status.svg)](https://godoc.org/github.com/go-playground/validator)
![License](https://img.shields.io/dub/l/vibe-d.svg)

Package validator implements value validations for structs and individual fields based on tags.
Expand All @@ -20,18 +20,18 @@ It has the following **unique** features:
- Alias validation tags, which allows for mapping of several validations to a single tag for easier defining of validations on structs
- Extraction of custom defined Field Name e.g. can specify to extract the JSON name while validating and have it available in the resulting FieldError
- Customizable i18n aware error messages.
- Default validator for the [gin](https://github.com/gin-gonic/gin) web framework; upgrading from v8 to v9 in gin see [here](https://github.com/go-playground/validator/tree/v9/_examples/gin-upgrading-overriding)
- Default validator for the [gin](https://github.com/gin-gonic/gin) web framework; upgrading from v8 to v9 in gin see [here](https://github.com/go-playground/validator/tree/master/_examples/gin-upgrading-overriding)

Installation
------------

Use go get.

go get gopkg.in/go-playground/validator.v9
go get github.com/go-playground/validator/v10

Then import the validator package into your own code.

import "gopkg.in/go-playground/validator.v9"
import "github.com/go-playground/validator/v10"

Error Return Value
-------
Expand All @@ -53,14 +53,14 @@ validationErrors := err.(validator.ValidationErrors)
Usage and documentation
------

Please see http://godoc.org/gopkg.in/go-playground/validator.v9 for detailed usage docs.
Please see http://godoc.org/github.com/go-playground/validator/v10 for detailed usage docs.

##### Examples:

- [Simple](https://github.com/go-playground/validator/blob/v9/_examples/simple/main.go)
- [Custom Field Types](https://github.com/go-playground/validator/blob/v9/_examples/custom/main.go)
- [Struct Level](https://github.com/go-playground/validator/blob/v9/_examples/struct-level/main.go)
- [Translations & Custom Errors](https://github.com/go-playground/validator/blob/v9/_examples/translations/main.go)
- [Simple](https://github.com/go-playground/validator/blob/master/_examples/simple/main.go)
- [Custom Field Types](https://github.com/go-playground/validator/blob/master/_examples/custom/main.go)
- [Struct Level](https://github.com/go-playground/validator/blob/master/_examples/struct-level/main.go)
- [Translations & Custom Errors](https://github.com/go-playground/validator/blob/master/_examples/translations/main.go)
- [Gin upgrade and/or override validator](https://github.com/go-playground/validator/tree/v9/_examples/gin-upgrading-overriding)
- [wash - an example application putting it all together](https://github.com/bluesuncorp/wash)

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

"gopkg.in/go-playground/validator.v9"
"github.com/go-playground/validator/v10"
)

// MyStruct ..
Expand Down
2 changes: 1 addition & 1 deletion _examples/custom/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"reflect"

"gopkg.in/go-playground/validator.v9"
"github.com/go-playground/validator/v10"
)

// DbBackedUser User struct
Expand Down
2 changes: 1 addition & 1 deletion _examples/dive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"gopkg.in/go-playground/validator.v9"
"github.com/go-playground/validator/v10"
)

// Test ...
Expand Down
2 changes: 1 addition & 1 deletion _examples/gin-upgrading-overriding/v8_to_v9.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"

"github.com/gin-gonic/gin/binding"
"gopkg.in/go-playground/validator.v9"
"github.com/go-playground/validator/v10"
)

type defaultValidator struct {
Expand Down
2 changes: 1 addition & 1 deletion _examples/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"gopkg.in/go-playground/validator.v9"
"github.com/go-playground/validator/v10"
)

// User contains user information
Expand Down
2 changes: 1 addition & 1 deletion _examples/struct-level/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"gopkg.in/go-playground/validator.v9"
"github.com/go-playground/validator/v10"
)

// User contains user information
Expand Down
4 changes: 2 additions & 2 deletions _examples/translations/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/go-playground/locales/en"
ut "github.com/go-playground/universal-translator"
"gopkg.in/go-playground/validator.v9"
en_translations "gopkg.in/go-playground/validator.v9/translations/en"
"github.com/go-playground/validator/v10"
en_translations "github.com/go-playground/validator/v10/translations/en"
)

// User contains user information
Expand Down
83 changes: 0 additions & 83 deletions examples_test.go

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/go-playground/validator/v10

go 1.13

require (
github.com/go-playground/assert/v2 v2.0.1
github.com/go-playground/locales v0.13.0
github.com/go-playground/universal-translator v0.17.0
github.com/leodido/go-urn v1.2.0
)
21 changes: 21 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
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.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
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=
2 changes: 1 addition & 1 deletion non-standard/validators/notblank.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"strings"

"gopkg.in/go-playground/validator.v9"
"github.com/go-playground/validator/v10"
)

// NotBlank is the validation function for validating if the current field
Expand Down
4 changes: 2 additions & 2 deletions non-standard/validators/notblank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package validators
import (
"testing"

"gopkg.in/go-playground/validator.v9"
"gopkg.in/go-playground/assert.v1"
"github.com/go-playground/validator/v10"
"github.com/go-playground/assert/v2"
)

type test struct {
Expand Down
2 changes: 1 addition & 1 deletion translations/en/en.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/go-playground/locales"
ut "github.com/go-playground/universal-translator"
"gopkg.in/go-playground/validator.v9"
"github.com/go-playground/validator/v10"
)

// RegisterDefaultTranslations registers a set of default translations
Expand Down
4 changes: 2 additions & 2 deletions translations/en/en_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

english "github.com/go-playground/locales/en"
ut "github.com/go-playground/universal-translator"
. "gopkg.in/go-playground/assert.v1"
"gopkg.in/go-playground/validator.v9"
. "github.com/go-playground/assert/v2"
"github.com/go-playground/validator/v10"
)

func TestTranslations(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion translations/fr/fr.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/go-playground/locales"
ut "github.com/go-playground/universal-translator"
"gopkg.in/go-playground/validator.v9"
"github.com/go-playground/validator/v10"
)

// RegisterDefaultTranslations registers a set of default translations
Expand Down
4 changes: 2 additions & 2 deletions translations/fr/fr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

french "github.com/go-playground/locales/fr"
ut "github.com/go-playground/universal-translator"
. "gopkg.in/go-playground/assert.v1"
"gopkg.in/go-playground/validator.v9"
. "github.com/go-playground/assert/v2"
"github.com/go-playground/validator/v10"
)

func TestTranslations(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion translations/id/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/go-playground/locales"
ut "github.com/go-playground/universal-translator"
"gopkg.in/go-playground/validator.v9"
"github.com/go-playground/validator/v10"
)

// RegisterDefaultTranslations registers a set of default translations
Expand Down
4 changes: 2 additions & 2 deletions translations/id/id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

indonesia "github.com/go-playground/locales/id"
ut "github.com/go-playground/universal-translator"
. "gopkg.in/go-playground/assert.v1"
"gopkg.in/go-playground/validator.v9"
. "github.com/go-playground/assert/v2"
"github.com/go-playground/validator/v10"
)

func TestTranslations(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion translations/ja/ja.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/go-playground/locales"
ut "github.com/go-playground/universal-translator"
"gopkg.in/go-playground/validator.v9"
"github.com/go-playground/validator/v10"
)

// RegisterDefaultTranslations registers a set of default translations
Expand Down
4 changes: 2 additions & 2 deletions translations/ja/ja_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

ja_locale "github.com/go-playground/locales/ja"
ut "github.com/go-playground/universal-translator"
. "gopkg.in/go-playground/assert.v1"
"gopkg.in/go-playground/validator.v9"
. "github.com/go-playground/assert/v2"
"github.com/go-playground/validator/v10"
)

func TestTranslations(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion translations/nl/nl.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/go-playground/locales"
ut "github.com/go-playground/universal-translator"
"gopkg.in/go-playground/validator.v9"
"github.com/go-playground/validator/v10"
)

// RegisterDefaultTranslations registers a set of default translations
Expand Down

0 comments on commit 7e57ca0

Please sign in to comment.