Skip to content

Commit

Permalink
Merge pull request #7 from twharmon/tag-name
Browse files Browse the repository at this point in the history
Tag name
  • Loading branch information
twharmon authored Nov 19, 2019
2 parents 63d23f2 + 9f9e63e commit 901fa94
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 48 deletions.
12 changes: 6 additions & 6 deletions bench/comparrison_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

type user struct {
ID int64
Name string `validate:"req|min:5|max:15|regex:^[a-zA-Z]+$"`
Email string `validate:"req|min:3|max:25|regex:^.+@.+$"`
Age int `validate:"min:3|max:120"`
Role string `validate:"in:admin,user,editor"`
FavoriteNumber int64 `validate:"req|min:1|max:999999999999999"`
Score float64 `validate:"req|min:3.33|max:10.45"`
Name string `govalid:"req|min:5|max:15|regex:^[a-zA-Z]+$"`
Email string `govalid:"req|min:3|max:25|regex:^.+@.+$"`
Age int `govalid:"min:3|max:120"`
Role string `govalid:"in:admin,user,editor"`
FavoriteNumber int64 `govalid:"req|min:1|max:999999999999999"`
Score float64 `govalid:"req|min:3.33|max:10.45"`
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module main

go 1.13

require github.com/twharmon/govalid v1.0.0
require github.com/twharmon/govalid v1.1.0

// replace github.com/twharmon/govalid => ../../../govalid
10 changes: 5 additions & 5 deletions examples/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
// User contains user information
type User struct {
ID int64
Name string `validate:"req|min:5|max:25,regex:^[a-zA-Z ]+$"`
Email string `validate:"req|min:3|max:100|regex:^.+?@.+?$"`
Age int `validate:"min:8|max:100"`
Role string `validate:"req|in:admin,editor,user"`
Grade float32 `validate:"min:0.0|max:100.0"`
Name string `govalid:"req|min:5|max:25,regex:^[a-zA-Z ]+$"`
Email string `govalid:"req|min:3|max:100|regex:^.+?@.+?$"`
Age int `govalid:"min:8|max:100"`
Role string `govalid:"req|in:admin,editor,user"`
Grade float32 `govalid:"min:0.0|max:100.0"`
}

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/custom/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module main

go 1.13

require github.com/twharmon/govalid v1.0.0
require github.com/twharmon/govalid v1.1.0

// replace github.com/twharmon/govalid => ../../../govalid
2 changes: 1 addition & 1 deletion examples/custom/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// User contains user information
type User struct {
ID int64
Name string `validate:"req"`
Name string `govalid:"req"`
}

func main() {
Expand Down
6 changes: 3 additions & 3 deletions float32_constraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ type f32 struct {
}

type f32Req struct {
F32 float32 `validate:"req"`
F32 float32 `govalid:"req"`
}

type f32ReqMin struct {
F32 float32 `validate:"req|min:5.5"`
F32 float32 `govalid:"req|min:5.5"`
}

type f32Max struct {
F32 float32 `validate:"max:5.5"`
F32 float32 `govalid:"max:5.5"`
}

func TestFloat32(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions float64_constraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ type f64 struct {
}

type f64Req struct {
F64 float64 `validate:"req"`
F64 float64 `govalid:"req"`
}

type f64ReqMin struct {
F64 float64 `validate:"req|min:5.5"`
F64 float64 `govalid:"req|min:5.5"`
}

type f64Max struct {
F64 float64 `validate:"max:5.5"`
F64 float64 `govalid:"max:5.5"`
}

type f64NullMax struct {
F64 sql.NullFloat64 `validate:"max:5.5"`
F64 sql.NullFloat64 `govalid:"max:5.5"`
}

func TestFloat64(t *testing.T) {
Expand Down
18 changes: 9 additions & 9 deletions govalid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,63 +79,63 @@ func TestRegister(t *testing.T) {

assertPanic(t, "when regex can't compile", func() {
type testBadRegex struct {
S string `validate:"regex:["`
S string `govalid:"regex:["`
}
govalid.Register(testBadRegex{})
})

assertPanic(t, "when int in won't parse", func() {
type testBadIntIn struct {
I int `validate:"in:4.3,5,6"`
I int `govalid:"in:4.3,5,6"`
}
govalid.Register(testBadIntIn{})
})

assertPanic(t, "when int64 in won't parse", func() {
type testBadIntIn struct {
I int `validate:"in:4.3,5,6"`
I int `govalid:"in:4.3,5,6"`
}
govalid.Register(testBadIntIn{})
})

assertPanic(t, "when int64 in won't parse", func() {
type testBadInt64In struct {
I int64 `validate:"in:4.3,5,6"`
I int64 `govalid:"in:4.3,5,6"`
}
govalid.Register(testBadInt64In{})
})

assertPanic(t, "when max int won't parse", func() {
type testBadMaxInt struct {
S string `validate:"max:4.3"`
S string `govalid:"max:4.3"`
}
govalid.Register(testBadMaxInt{})
})

assertPanic(t, "when max int64 won't parse", func() {
type testBadMaxInt64 struct {
I64 int64 `validate:"max:4.3"`
I64 int64 `govalid:"max:4.3"`
}
govalid.Register(testBadMaxInt64{})
})

assertPanic(t, "when max float32 won't parse", func() {
type testBadMaxFloat32 struct {
F32 float32 `validate:"max:4.g3"`
F32 float32 `govalid:"max:4.g3"`
}
govalid.Register(testBadMaxFloat32{})
})

assertPanic(t, "when max float64 won't parse", func() {
type testBadMaxFloat64 struct {
F64 float64 `validate:"max:4.g3"`
F64 float64 `govalid:"max:4.g3"`
}
govalid.Register(testBadMaxFloat64{})
})

assertNoPanic(t, "when ptr is registered", func() {
type testBadMaxFloat64 struct {
F64 float64 `validate:"max:4.3"`
F64 float64 `govalid:"max:4.3"`
}
govalid.Register(&testBadMaxFloat64{})
})
Expand Down
10 changes: 5 additions & 5 deletions int64_constraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ type i64 struct {
}

type i64Req struct {
I64 int64 `validate:"req"`
I64 int64 `govalid:"req"`
}

type i64Min struct {
I64 int64 `validate:"min:5"`
I64 int64 `govalid:"min:5"`
}

type i64Max struct {
I64 int64 `validate:"max:5"`
I64 int64 `govalid:"max:5"`
}

type i64ReqIn struct {
I64 int64 `validate:"req|in:1,2,3"`
I64 int64 `govalid:"req|in:1,2,3"`
}

type i64NullMin struct {
I64 sql.NullInt64 `validate:"req|min:5"`
I64 sql.NullInt64 `govalid:"req|min:5"`
}

func TestInt64(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions int_constraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ type i struct {
}

type iReq struct {
I int `validate:"req"`
I int `govalid:"req"`
}

type iMin struct {
I int `validate:"min:5"`
I int `govalid:"min:5"`
}

type iReqMax struct {
I int `validate:"req|max:5"`
I int `govalid:"req|max:5"`
}

type iIn struct {
I int `validate:"in:1,2,3"`
I int `govalid:"in:1,2,3"`
}

func TestInt(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
)

const tagKey = "validate"
const tagKey = "govalid"

type model struct {
name string
Expand Down
12 changes: 6 additions & 6 deletions string_constraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ type str struct {
}

type strReq struct {
S string `validate:"req"`
S string `govalid:"req"`
}

type strMin struct {
S string `validate:"min:5"`
S string `govalid:"min:5"`
}

type strReqMax struct {
ignoredField string
S string `validate:"req|max:5"`
S string `govalid:"req|max:5"`
}

type strRegex struct {
S string `validate:"regex:^[a-z]+$"`
S string `govalid:"regex:^[a-z]+$"`
}

type strIn struct {
S string `validate:"in:abc,def,ghi"`
S string `govalid:"in:abc,def,ghi"`
}

type strNullMax struct {
S sql.NullString `validate:"max:5"`
S sql.NullString `govalid:"max:5"`
}

func TestString(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions time_constraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ type tm struct {
}

type tmMin struct {
T time.Time `validate:"min:0"`
T time.Time `govalid:"min:0"`
}

type tmNullMax struct {
T gosql.NullTime `validate:"req|max:3600"`
T gosql.NullTime `govalid:"req|max:3600"`
}

func TestTime(t *testing.T) {
Expand Down

0 comments on commit 901fa94

Please sign in to comment.