Skip to content

Commit

Permalink
updated validator integration
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed Jul 25, 2024
1 parent 8938a04 commit f86923a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 30 deletions.
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/viant/parsly v0.3.3-0.20240717150634-e1afaedb691b
github.com/viant/pgo v0.11.0
github.com/viant/scy v0.10.0
github.com/viant/sqlx v0.14.1-0.20240724211303-844af16823da
github.com/viant/sqlx v0.15.0
github.com/viant/structql v0.4.2-0.20240712002135-b1ef22dd834f
github.com/viant/toolbox v0.36.0
github.com/viant/velty v0.2.1-0.20230927172116-ba56497b5c85
Expand All @@ -44,19 +44,19 @@ require (
)

require (
github.com/viant/govalidator v0.2.2
github.com/viant/govalidator v0.3.0
github.com/viant/sqlparser v0.7.1-0.20240717151907-216ea35d127a
golang.org/x/crypto v0.22.0
golang.org/x/crypto v0.22.0 // indirect
)

require (
firebase.google.com/go/v4 v4.14.0
github.com/viant/aerospike v0.1.0
github.com/viant/structology v0.5.6-0.20240724183243-379c7ed6e097
github.com/viant/tagly v0.2.1-0.20240521205717-55de744e893c
github.com/viant/xdatly v0.3.1-0.20240724214307-abece0437c33
github.com/viant/xdatly v0.4.0
github.com/viant/xdatly/extension v0.0.0-20231013204918-ecf3c2edf259
github.com/viant/xdatly/handler v0.0.0-20240724214307-abece0437c33
github.com/viant/xdatly/handler v0.0.0-20240725144805-672af29559ba
github.com/viant/xdatly/types/core v0.0.0-20240109065401-9758ebacb4bb
github.com/viant/xdatly/types/custom v0.0.0-20240624200855-79bbed0d3db9
github.com/viant/xlsy v0.3.0
Expand Down Expand Up @@ -146,3 +146,4 @@ require (
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

23 changes: 2 additions & 21 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1083,9 +1083,6 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
github.com/viant/aerospike v0.0.0-20240719102851-c409b7cb20da h1:jlbYxz3NX4YfReg5l40x0MPb7V81KUhi48ctFp36GUs=
github.com/viant/aerospike v0.0.0-20240719102851-c409b7cb20da/go.mod h1:a0p84jBzUfRKLhPIe2HJzsil/lTqfnNHd5oVsfPm7sM=
github.com/viant/aerospike v0.0.0-20240722133740-00e541ae8f36/go.mod h1:0bFTo5IjbRAk8NpeX0F4GExehaz7BzyuVYDw8uLSews=
github.com/viant/aerospike v0.1.0 h1:42iPJOG6auRWSOolaKhDR35LO+n/8sYICvNdOKEhZ+A=
github.com/viant/aerospike v0.1.0/go.mod h1:0bFTo5IjbRAk8NpeX0F4GExehaz7BzyuVYDw8uLSews=
github.com/viant/afs v1.25.1-0.20231110184132-877ed98abca1 h1:q83rO9rKNCsT/W9x9EBmCVt24yjFDRmhslLhaL4h7DE=
Expand All @@ -1110,28 +1107,20 @@ github.com/viant/gmetric v0.3.1-0.20230405233616-cc90deee60c4 h1:Lz5up/Q1N8A5pch
github.com/viant/gmetric v0.3.1-0.20230405233616-cc90deee60c4/go.mod h1:RHqj7bdVZrPahrhQxhZRsFX3p/I7ixUEt7+G3l5z+v0=
github.com/viant/godiff v0.4.1 h1:pjMA4zOz/mNcXRvl+CjWzg3m8XwOFBjaxDqfUYQXb9M=
github.com/viant/godiff v0.4.1/go.mod h1:/q54pjC31YIOqbPcQnqwF2/dAZlnIr1SdQOtqoa0MpQ=
github.com/viant/govalidator v0.2.2 h1:9EWbLUQ7M5c9ZAGsi8SZsNdKs4KT46Cy4Tu30mAISZY=
github.com/viant/govalidator v0.2.2/go.mod h1:D35Dwx0R8rR1knRxhlseoYvOkiqo24kpMg1/o977i9Y=
github.com/viant/igo v0.2.0 h1:ygWmTCinnGPaeV7omJLiyneOpzYZ5kiw7oYz7mUJZVQ=
github.com/viant/igo v0.2.0/go.mod h1:7V6AWsLhKWeGzXNTNH3AZiIEKa0m33DrQbdWtapsI74=
github.com/viant/parsly v0.3.3-0.20240717150634-e1afaedb691b h1:3q166tV28yFdbFV+tXXjH7ViKAmgAgGdoWzMtvhQv28=
github.com/viant/parsly v0.3.3-0.20240717150634-e1afaedb691b/go.mod h1:85fneXJbErKMGhSQto3A5ElTQCwl3t74U9cSV0waBHw=
github.com/viant/pgo v0.11.0 h1:PNuYVhwTfyrAHGBO6lxaMFuHP4NkjKV8ULecz3OWk8c=
github.com/viant/pgo v0.11.0/go.mod h1:MFzHmkRFZlciugEgUvpl/3grK789PBSH4dUVSLOSo+Q=
github.com/viant/scy v0.9.1 h1:tRNgHkX5JwscIZ0c/1zrHCzyyMc5bS+kNLTHoemwWzk=
github.com/viant/scy v0.9.1/go.mod h1:vXJWbdyy66rDS2VXSznBnFy3bPV+WVjkhKd/R2yuMdA=
github.com/viant/scy v0.10.0 h1:uw13kR0qY98SkR9RoIjhJiRnF5oK1VKQUv/RxOc3s58=
github.com/viant/scy v0.10.0/go.mod h1:Lz1VPlmjVi4ydZ5ikP/d5uQS/xYs22HG23++PgLRlKQ=
github.com/viant/sqlparser v0.7.1-0.20240717151907-216ea35d127a h1:2ijg6j7HlXU6S1gHAfWPLJ7x4Dqo1OgIlJU2niKK59s=
github.com/viant/sqlparser v0.7.1-0.20240717151907-216ea35d127a/go.mod h1:2QRGiGZYk2/pjhORGG1zLVQ9JO+bXFhqIVi31mkCRPg=
github.com/viant/sqlx v0.12.1-0.20240613223731-980e9de11f2f h1:24wEZ4qpkz2Pw4/CDzV3XLCkvof+RtSzI0jC462ySKA=
github.com/viant/sqlx v0.12.1-0.20240613223731-980e9de11f2f/go.mod h1:gHaDVhZAGYF6l3OP8Pd9FZ/p6tZaani47dwDWDUYTWM=
github.com/viant/sqlx v0.14.0 h1:Oo24jemDcPRr0jien3P9JkuKpMyO1Als6qQKt3lRCvE=
github.com/viant/sqlx v0.14.0/go.mod h1:9IPs8WgNP/jwMbxcDlhYPpSPJkGdqGwCFDWXFNJJQHo=
github.com/viant/sqlx v0.14.1-0.20240724211303-844af16823da h1:yurIK5EIOx4He0whzmVemWMf2NaeoxPHX6RBiZR4Kbo=
github.com/viant/sqlx v0.14.1-0.20240724211303-844af16823da/go.mod h1:9IPs8WgNP/jwMbxcDlhYPpSPJkGdqGwCFDWXFNJJQHo=
github.com/viant/structology v0.5.6-0.20240715114555-e89beafaa7b8 h1:iRCcDHodY0SXCckN87x6M/wEuJEM/4r/KqL1hF35B6U=
github.com/viant/structology v0.5.6-0.20240715114555-e89beafaa7b8/go.mod h1:63XfkzUyNw7wdi99HJIsH2Rg3d5AOumqbWLUYytOkxU=
github.com/viant/sqlx v0.15.0 h1:tuFT9uaIgI/UTbQHDukeWER1l54bm2W1o6wZ1oiw4Vs=
github.com/viant/sqlx v0.15.0/go.mod h1:9IPs8WgNP/jwMbxcDlhYPpSPJkGdqGwCFDWXFNJJQHo=
github.com/viant/structology v0.5.6-0.20240724183243-379c7ed6e097 h1:G/dMlvkw9MQJQ777iBWf/lWFW4793aTLbvyvlMfVUQY=
github.com/viant/structology v0.5.6-0.20240724183243-379c7ed6e097/go.mod h1:63XfkzUyNw7wdi99HJIsH2Rg3d5AOumqbWLUYytOkxU=
github.com/viant/structql v0.4.2-0.20240712002135-b1ef22dd834f h1:B9+Qhjh0Owb2SzNwrRBYSGvAp1kNRDgZoVKPXmcsKP0=
Expand All @@ -1146,16 +1135,8 @@ github.com/viant/velty v0.2.1-0.20230927172116-ba56497b5c85 h1:zKk+6hqUipkJXCPCH
github.com/viant/velty v0.2.1-0.20230927172116-ba56497b5c85/go.mod h1:Q/UXviI2Nli8WROEpYd/BELMCSvnulQeyNrbPmMiS/Y=
github.com/viant/x v0.3.0 h1:/3A0z/uySGxMo6ixH90VAcdjI00w5e3REC1zg5hzhJA=
github.com/viant/x v0.3.0/go.mod h1:54jP3qV+nnQdNDaWxEwGTAAzCu9sx9er9htiwTW/Mcw=
github.com/viant/xdatly v0.3.1-0.20240710035338-b561698d2bf4 h1:e9Lz9ebRr/bu71yPx2WC9VzXA2Q64rskNwliuQbKlKY=
github.com/viant/xdatly v0.3.1-0.20240710035338-b561698d2bf4/go.mod h1:YwNS31k5r1Ldw5s7wmQXUKaalN6BWcfX9qePO/b/ilc=
github.com/viant/xdatly v0.3.1-0.20240724214307-abece0437c33 h1:uw3WRYL6voRSFjsPtDf0Ne6RzbjGvEZezblwa4GZKgg=
github.com/viant/xdatly v0.3.1-0.20240724214307-abece0437c33/go.mod h1:YwNS31k5r1Ldw5s7wmQXUKaalN6BWcfX9qePO/b/ilc=
github.com/viant/xdatly/extension v0.0.0-20231013204918-ecf3c2edf259 h1:9Yry3PUBDzc4rWacOYvAq/TKrTV0agvMF0gwm2gaoHI=
github.com/viant/xdatly/extension v0.0.0-20231013204918-ecf3c2edf259/go.mod h1:fb8YgbVadk8X5ZLz49LWGzWmQlZd7Y/I5wE0ru44bIo=
github.com/viant/xdatly/handler v0.0.0-20240710035338-b561698d2bf4 h1:JaEVpYI0lLFPJfm3sh3M3uyGakd2uoUOHX14mzePIO0=
github.com/viant/xdatly/handler v0.0.0-20240710035338-b561698d2bf4/go.mod h1:bBa479sCB55VymMrXFccluUFkf6oRI77xhtnWIcL8K0=
github.com/viant/xdatly/handler v0.0.0-20240724214307-abece0437c33 h1:wc/YJ5OGdoohEa2XFRFizmDaiumIbLJjTShBBmKBioE=
github.com/viant/xdatly/handler v0.0.0-20240724214307-abece0437c33/go.mod h1:bBa479sCB55VymMrXFccluUFkf6oRI77xhtnWIcL8K0=
github.com/viant/xdatly/types/core v0.0.0-20240109065401-9758ebacb4bb h1:X4emK6TIR6IXiFlQz9wEdCi5RJMG3dg3e8+VLQ2zhnM=
github.com/viant/xdatly/types/core v0.0.0-20240109065401-9758ebacb4bb/go.mod h1:LJN2m8xJjtYNCvyvNrVanJwvzj8+hYCuPswL8H4qRG0=
github.com/viant/xdatly/types/custom v0.0.0-20240624200855-79bbed0d3db9 h1:+wndga8eeCHI9NWUmX2/bpn16pbwK06ezC8drBmZAKw=
Expand Down
15 changes: 11 additions & 4 deletions service/executor/extension/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ func (v *Validator) validateWithGoValidator(ctx context.Context, any interface{}
if options.WithSetMarker {
gOptions = append(gOptions, govalidator.WithSetMarker())
}
if options.CanUseMarkerProvider != nil {
gOptions = append(gOptions, govalidator.WithCanUseMarkerProvider(govalidator.CanUseMarkerProvider(options.CanUseMarkerProvider)))
}
if options.Location != "" {
rootPath := govalidator.NewPath()
gOptions = append(gOptions, govalidator.WithPath(rootPath.Field(options.Location)))
}

ret, err := goValidator.Validate(ctx, any, gOptions...)
if ret != nil && len(ret.Violations) > 0 {
Expand All @@ -96,13 +103,13 @@ func (v *Validator) validateWithSqlx(ctx context.Context, any interface{}, valid
if len(sqlxOptions) == 0 {
return nil
}
if options.WithShallow {
sqlxOptions = append(sqlxOptions, sqlxvalidator.WithShallow(true))
}
if options.Location != "" {
sqlxOptions = append(sqlxOptions, sqlxvalidator.WithLocation(options.Location))
}

if options.WithSetMarker {
sqlxOptions = append(sqlxOptions, sqlxvalidator.WithSetMarker())
}
sqlxOptions = append(sqlxOptions, sqlxvalidator.WithSetMarker())
ret, err := sqlxValidator.Validate(ctx, db, any, sqlxOptions...)
if ret != nil && len(ret.Violations) > 0 {
validation.Violations = httputils.Violations(validation.Violations).MergeSqlViolation(ret.Violations)
Expand Down

0 comments on commit f86923a

Please sign in to comment.