Skip to content

Commit e22293e

Browse files
committed
bring schema package in and denormalize
1 parent 76574c4 commit e22293e

22 files changed

+471
-29
lines changed

add_error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package changeset
22

3-
// Error defines information about grimoire's error.
3+
// Error struct.
44
type Error struct {
55
Message string `json:"message"`
66
Field string `json:"field,omitempty"`

apply_string_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"strings"
55
"testing"
66

7-
"github.com/Fs02/form/params"
7+
"github.com/Fs02/changeset/params"
88
"github.com/stretchr/testify/assert"
99
)
1010

cast.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import (
55
"reflect"
66
"strings"
77

8-
"github.com/Fs02/form/params"
9-
"github.com/Fs02/grimoire/schema"
8+
"github.com/Fs02/changeset/params"
109
)
1110

1211
// CastErrorMessage is the default error message for Cast.
@@ -62,9 +61,9 @@ func Cast(data interface{}, params params.Params, fields []string, opts ...Optio
6261

6362
func mapSchema(data interface{}, zero bool) (map[string]interface{}, map[string]reflect.Type, bool) {
6463
var (
65-
fields = schema.InferFields(data)
66-
types = schema.InferTypes(data)
67-
values = schema.InferValues(data)
64+
fields = inferFields(data)
65+
types = inferTypes(data)
66+
values = inferValues(data)
6867
valuesMap = make(map[string]interface{}, len(fields))
6968
typesMap = make(map[string]reflect.Type, len(fields))
7069
)

cast_assoc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strconv"
66
"strings"
77

8-
"github.com/Fs02/form/params"
8+
"github.com/Fs02/changeset/params"
99
)
1010

1111
// CastAssocErrorMessage is the default error message for CastAssoc when its invalid.

cast_assoc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"reflect"
55
"testing"
66

7-
"github.com/Fs02/form/params"
7+
"github.com/Fs02/changeset/params"
88
"github.com/stretchr/testify/assert"
99
)
1010

cast_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"reflect"
66
"testing"
77

8-
"github.com/Fs02/form/params"
8+
"github.com/Fs02/changeset/params"
99
"github.com/stretchr/testify/assert"
1010
)
1111

changeset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package changeset
44
import (
55
"reflect"
66

7-
"github.com/Fs02/form/params"
7+
"github.com/Fs02/changeset/params"
88
)
99

1010
// Changeset used to cast and validate data before saving it to the database.

escape_string_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package changeset
33
import (
44
"testing"
55

6-
"github.com/Fs02/form/params"
6+
"github.com/Fs02/changeset/params"
77
"github.com/stretchr/testify/assert"
88
)
99

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
module github.com/Fs02/form
1+
module github.com/Fs02/changeset
22

33
go 1.13
44

55
require (
6-
github.com/Fs02/grimoire v1.4.3
76
github.com/Fs02/rel v0.4.0
7+
github.com/azer/snakecase v0.0.0-20161028114325-c818dddafb5c
88
github.com/stretchr/testify v1.5.1
99
github.com/tidwall/gjson v1.6.0
1010
)

go.sum

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
github.com/Fs02/go-paranoid v0.0.0-20180516074805-ab50069def7d/go.mod h1:mUYWV9DG75bJ33LZlW1Je3MW64017zkfUFCf+QnCJs0=
21
github.com/Fs02/go-paranoid v0.0.0-20190122110906-018c1ac5124a/go.mod h1:mUYWV9DG75bJ33LZlW1Je3MW64017zkfUFCf+QnCJs0=
3-
github.com/Fs02/grimoire v1.4.3 h1:ZZUtx0r1HmwonQtLNDBPZlO6az1n6DP3hBS++qoKr0g=
4-
github.com/Fs02/grimoire v1.4.3/go.mod h1:hjryvs3ViaQZ9BFU7xLUOtQS01WXCVyY7loi4q19u1o=
52
github.com/Fs02/rel v0.4.0 h1:iop6aPDb2gfTIxYIbFq1sTEMJzSjlryb+mfFkSqgeig=
63
github.com/Fs02/rel v0.4.0/go.mod h1:MeJHkZO46QVfjagPSnYX/noguNDOqNK2LLGse77asxw=
74
github.com/azer/snakecase v0.0.0-20161028114325-c818dddafb5c h1:7zL0ljVI6ads5EFvx+Oq+uompnFBMJqtbuHvyobbJ1Q=
@@ -13,31 +10,30 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
1310
github.com/go-sql-driver/mysql v1.3.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
1411
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a h1:eeaG9XMUvRBYXJi4pg1ZKM7nxc5AfXfojeLLW7O5J3k=
1512
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
13+
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
1614
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
1715
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
16+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
1817
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
19-
github.com/lib/pq v0.0.0-20180327071824-d34b9ff171c2/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
2018
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
2119
github.com/mattn/go-sqlite3 v1.6.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
2220
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2321
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2422
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
2523
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
2624
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
27-
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
2825
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
2926
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
3027
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
3128
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
32-
github.com/tidwall/gjson v1.1.3/go.mod h1:c/nTNbUr0E0OrXEhq1pwa8iEgc2DOt4ZZqAt1HtCkPA=
3329
github.com/tidwall/gjson v1.6.0 h1:9VEQWz6LLMUsUl6PueE49ir4Ka6CzLymOAZDxpFsTDc=
3430
github.com/tidwall/gjson v1.6.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
35-
github.com/tidwall/match v1.0.0/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
3631
github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc=
3732
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
3833
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
3934
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
4035
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
36+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
4137
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
4238
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
4339
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

0 commit comments

Comments
 (0)