diff --git a/assets/group.go b/assets/group.go index d520aa283..7a7806147 100644 --- a/assets/group.go +++ b/assets/group.go @@ -3,9 +3,9 @@ package assets import ( "fmt" + "github.com/go-playground/validator/v10" "github.com/nyaruka/gocommon/uuids" "github.com/nyaruka/goflow/utils" - validator "gopkg.in/go-playground/validator.v9" ) func init() { diff --git a/assets/label.go b/assets/label.go index 3978f8684..9a34d1dea 100644 --- a/assets/label.go +++ b/assets/label.go @@ -3,9 +3,9 @@ package assets import ( "fmt" + "github.com/go-playground/validator/v10" "github.com/nyaruka/gocommon/uuids" "github.com/nyaruka/goflow/utils" - validator "gopkg.in/go-playground/validator.v9" ) func init() { diff --git a/assets/user.go b/assets/user.go index b8c07b385..898e82002 100644 --- a/assets/user.go +++ b/assets/user.go @@ -3,9 +3,9 @@ package assets import ( "fmt" + "github.com/go-playground/validator/v10" "github.com/nyaruka/gocommon/jsonx" "github.com/nyaruka/goflow/utils" - validator "gopkg.in/go-playground/validator.v9" ) func init() { diff --git a/envs/country.go b/envs/country.go index 90036d821..aed90cdc4 100644 --- a/envs/country.go +++ b/envs/country.go @@ -3,10 +3,10 @@ package envs import ( "database/sql/driver" - "github.com/nyaruka/gocommon/dbutil" + "github.com/go-playground/validator/v10" "github.com/nyaruka/goflow/utils" + "github.com/nyaruka/null/v2" "github.com/nyaruka/phonenumbers" - validator "gopkg.in/go-playground/validator.v9" ) func init() { @@ -30,6 +30,8 @@ func DeriveCountryFromTel(number string) Country { return Country(phonenumbers.GetRegionCodeForNumber(parsed)) } -// Place nicely with NULLs if persisting to a database -func (c *Country) Scan(v any) error { return dbutil.ScanNullString(v, c) } -func (c Country) Value() (driver.Value, error) { return dbutil.NullStringValue(c) } +// Place nicely with NULLs if persisting to a database or JSON +func (c *Country) Scan(value any) error { return null.ScanString(value, c) } +func (c Country) Value() (driver.Value, error) { return null.StringValue(c) } +func (c Country) MarshalJSON() ([]byte, error) { return null.MarshalString(c) } +func (c *Country) UnmarshalJSON(b []byte) error { return null.UnmarshalString(b, c) } diff --git a/envs/dates.go b/envs/dates.go index 162e96f95..28b571545 100644 --- a/envs/dates.go +++ b/envs/dates.go @@ -7,11 +7,10 @@ import ( "strings" "time" + "github.com/go-playground/validator/v10" "github.com/nyaruka/gocommon/dates" "github.com/nyaruka/goflow/utils" - "github.com/pkg/errors" - validator "gopkg.in/go-playground/validator.v9" ) func init() { diff --git a/envs/language.go b/envs/language.go index 2ac884768..1e381c753 100644 --- a/envs/language.go +++ b/envs/language.go @@ -3,11 +3,11 @@ package envs import ( "database/sql/driver" - "github.com/nyaruka/gocommon/dbutil" + "github.com/go-playground/validator/v10" "github.com/nyaruka/goflow/utils" + "github.com/nyaruka/null/v2" "github.com/pkg/errors" "golang.org/x/text/language" - "gopkg.in/go-playground/validator.v9" ) func init() { @@ -36,6 +36,8 @@ func ParseLanguage(lang string) (Language, error) { return Language(base.ISO3()), nil } -// Place nicely with NULLs if persisting to a database -func (l *Language) Scan(v any) error { return dbutil.ScanNullString(v, l) } -func (l Language) Value() (driver.Value, error) { return dbutil.NullStringValue(l) } +// Place nicely with NULLs if persisting to a database or JSON +func (l *Language) Scan(value any) error { return null.ScanString(value, l) } +func (l Language) Value() (driver.Value, error) { return null.StringValue(l) } +func (l Language) MarshalJSON() ([]byte, error) { return null.MarshalString(l) } +func (l *Language) UnmarshalJSON(b []byte) error { return null.UnmarshalString(b, l) } diff --git a/envs/locale.go b/envs/locale.go index 889267cc6..a47c250c0 100644 --- a/envs/locale.go +++ b/envs/locale.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/nyaruka/gocommon/dbutil" + "github.com/nyaruka/null/v2" "golang.org/x/text/language" ) @@ -66,6 +66,8 @@ func (l Locale) ToParts() (Language, Country) { var NilLocale = Locale("") -// Place nicely with NULLs if persisting to a database -func (l *Locale) Scan(v any) error { return dbutil.ScanNullString(v, l) } -func (l Locale) Value() (driver.Value, error) { return dbutil.NullStringValue(l) } +// Place nicely with NULLs if persisting to a database or JSON +func (l *Locale) Scan(value any) error { return null.ScanString(value, l) } +func (l Locale) Value() (driver.Value, error) { return null.StringValue(l) } +func (l Locale) MarshalJSON() ([]byte, error) { return null.MarshalString(l) } +func (l *Locale) UnmarshalJSON(b []byte) error { return null.UnmarshalString(b, l) } diff --git a/flows/contact.go b/flows/contact.go index 8e22bc4d8..ca6ebc548 100644 --- a/flows/contact.go +++ b/flows/contact.go @@ -6,6 +6,7 @@ import ( "strconv" "time" + "github.com/go-playground/validator/v10" "github.com/nyaruka/gocommon/dates" "github.com/nyaruka/gocommon/jsonx" "github.com/nyaruka/gocommon/urns" @@ -15,10 +16,8 @@ import ( "github.com/nyaruka/goflow/envs" "github.com/nyaruka/goflow/excellent/types" "github.com/nyaruka/goflow/utils" - "github.com/shopspring/decimal" - "github.com/pkg/errors" - validator "gopkg.in/go-playground/validator.v9" + "github.com/shopspring/decimal" ) func init() { diff --git a/flows/flows.go b/flows/flows.go index b2b62d47d..21dc8e6e1 100644 --- a/flows/flows.go +++ b/flows/flows.go @@ -1,9 +1,8 @@ package flows import ( + "github.com/go-playground/validator/v10" "github.com/nyaruka/goflow/utils" - - validator "gopkg.in/go-playground/validator.v9" ) func init() { diff --git a/flows/ivr.go b/flows/ivr.go index 48a7f2341..db7944de5 100644 --- a/flows/ivr.go +++ b/flows/ivr.go @@ -1,11 +1,10 @@ package flows import ( + "github.com/go-playground/validator/v10" "github.com/nyaruka/goflow/envs" "github.com/nyaruka/goflow/excellent/types" "github.com/nyaruka/goflow/utils" - - validator "gopkg.in/go-playground/validator.v9" ) func init() { diff --git a/flows/modifiers/testdata/language.json b/flows/modifiers/testdata/language.json index e9afbfa51..761ba9269 100644 --- a/flows/modifiers/testdata/language.json +++ b/flows/modifiers/testdata/language.json @@ -74,7 +74,7 @@ }, "modifier": { "type": "language", - "language": "" + "language": null }, "contact_after": { "uuid": "5d76d86b-3bb9-4d5a-b822-c9d86f5d8e4f", diff --git a/flows/msg.go b/flows/msg.go index f15c7e157..41388b915 100644 --- a/flows/msg.go +++ b/flows/msg.go @@ -3,13 +3,12 @@ package flows import ( "fmt" + "github.com/go-playground/validator/v10" "github.com/nyaruka/gocommon/urns" "github.com/nyaruka/gocommon/uuids" "github.com/nyaruka/goflow/assets" "github.com/nyaruka/goflow/envs" "github.com/nyaruka/goflow/utils" - - validator "gopkg.in/go-playground/validator.v9" ) func init() { diff --git a/flows/urn.go b/flows/urn.go index aea6188a3..37eca7451 100644 --- a/flows/urn.go +++ b/flows/urn.go @@ -4,13 +4,12 @@ import ( "fmt" "net/url" + "github.com/go-playground/validator/v10" "github.com/nyaruka/gocommon/urns" "github.com/nyaruka/goflow/assets" "github.com/nyaruka/goflow/envs" "github.com/nyaruka/goflow/excellent/types" "github.com/nyaruka/goflow/utils" - - validator "gopkg.in/go-playground/validator.v9" ) var redacted = "********" @@ -38,10 +37,9 @@ func ValidateURNScheme(fl validator.FieldLevel) bool { // ContactURN represents a destination for an outgoing message or a source of an incoming message. It is string composed of 3 // components: scheme, path, and display (optional). For example: // -// - _tel:+16303524567_ -// - _twitterid:54784326227#nyaruka_ -// - _telegram:34642632786#bobby_ -// +// - _tel:+16303524567_ +// - _twitterid:54784326227#nyaruka_ +// - _telegram:34642632786#bobby_ type ContactURN struct { urn urns.URN channel *Channel diff --git a/go.mod b/go.mod index ba123876a..c7ab5bfff 100644 --- a/go.mod +++ b/go.mod @@ -6,35 +6,36 @@ require ( github.com/Masterminds/semver v1.5.0 github.com/Shopify/gomail v0.0.0-20220729171026-0784ece65e69 github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220527190237-ee62e23da966 - github.com/blevesearch/segment v0.9.0 + github.com/blevesearch/segment v0.9.1 github.com/buger/jsonparser v1.1.1 - github.com/nyaruka/gocommon v1.34.0 - github.com/nyaruka/phonenumbers v1.1.4 + github.com/go-playground/validator/v10 v10.11.2 + github.com/nyaruka/gocommon v1.34.1 + github.com/nyaruka/null/v2 v2.0.0 + github.com/nyaruka/phonenumbers v1.1.5 github.com/olivere/elastic/v7 v7.0.32 github.com/pkg/errors v0.9.1 - github.com/sergi/go-diff v1.2.0 + github.com/sergi/go-diff v1.3.1 github.com/shopspring/decimal v1.3.1 github.com/stretchr/testify v1.8.1 - golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 - golang.org/x/net v0.2.0 - golang.org/x/text v0.4.0 - gopkg.in/go-playground/validator.v9 v9.31.0 + golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 + golang.org/x/net v0.5.0 + golang.org/x/text v0.6.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/gabriel-vasile/mimetype v1.4.1 // indirect github.com/go-chi/chi v4.1.2+incompatible // indirect - github.com/go-playground/locales v0.14.0 // indirect - github.com/go-playground/universal-translator v0.18.0 // indirect - github.com/gofrs/uuid v4.3.1+incompatible // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/gofrs/uuid v4.4.0+incompatible // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/jmoiron/sqlx v1.3.5 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/leodido/go-urn v1.2.1 // indirect - github.com/lib/pq v1.10.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/crypto v0.5.0 // indirect + golang.org/x/sys v0.4.0 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index bac8c0fa2..d38a3eb71 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/Shopify/gomail v0.0.0-20220729171026-0784ece65e69 h1:gPoXdwo3sKq8qcfM github.com/Shopify/gomail v0.0.0-20220729171026-0784ece65e69/go.mod h1:RS+Gaowa0M+gCuiFAiRMGBCMqxLrNA7TESTU/Wbblm8= github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220527190237-ee62e23da966 h1:mEzJ8SH4M5wDL8C4a17yX2YeD/FIXV5w8FJekByaBi0= github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220527190237-ee62e23da966/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= -github.com/blevesearch/segment v0.9.0 h1:5lG7yBCx98or7gK2cHMKPukPZ/31Kag7nONpoBt22Ac= -github.com/blevesearch/segment v0.9.0/go.mod h1:9PfHYUdQCgHktBgvtUOF4x+pc4/l8rdH0u5spnW85UQ= +github.com/blevesearch/segment v0.9.1 h1:+dThDy+Lvgj5JMxhmOVlgFfkUtZV2kw49xax4+jTfSU= +github.com/blevesearch/segment v0.9.1/go.mod h1:zN21iLm7+GnBHWTao9I+Au/7MBiL8pPFtJBJTsk6kQw= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -16,49 +16,48 @@ github.com/gabriel-vasile/mimetype v1.4.1 h1:TRWk7se+TOjCYgRth7+1/OYLNiRNIotknkF github.com/gabriel-vasile/mimetype v1.4.1/go.mod h1:05Vi0w3Y9c/lNvJOdmIwvrrAhX3rYhfQQCaf9VJcv7M= github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec= github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= -github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= -github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= -github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= -github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= -github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/gofrs/uuid v4.3.1+incompatible h1:0/KbAdpx3UXAx1kEOWHJeOkpbgRFGHVgv+CFIY7dBJI= -github.com/gofrs/uuid v4.3.1+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU= +github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s= +github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= +github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= -github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= -github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg= -github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/nyaruka/gocommon v1.34.0 h1:efIqt2ZlN4WAvXylId/sNnNSOlgo4oGxSJLNLg2W21c= -github.com/nyaruka/gocommon v1.34.0/go.mod h1:gusIA2aNC8EPB3ozlP4O0PaBiHUNq5+f1peRNvcn0DI= -github.com/nyaruka/phonenumbers v1.1.4 h1:de8exybd7+g9q+gXP04Ypt9ijFYXXm8wrgqPf+Ckk20= -github.com/nyaruka/phonenumbers v1.1.4/go.mod h1:yShPJHDSH3aTKzCbXyVxNpbl2kA+F+Ne5Pun/MvFRos= +github.com/nyaruka/gocommon v1.34.1 h1:uFRxnhuyVzfr7YqontNr/ryuALMBjjmhVHCJI1ASsGg= +github.com/nyaruka/gocommon v1.34.1/go.mod h1:tTa8b2obZuQQytsL2ts3pV72dUbRW9w5Qaq/V5YfW/8= +github.com/nyaruka/null/v2 v2.0.0 h1:qcojHJ/uIGpkrM4UTEeccU0rHGNGT1np0Dqarvhjizs= +github.com/nyaruka/null/v2 v2.0.0/go.mod h1:OCVeCkCXwrg5/qE6RU0c1oUVZBy+ZDrT+xYg1XSaIWA= +github.com/nyaruka/phonenumbers v1.1.5 h1:vYy2DI+z5hdaemqVzXYJ4CVyK92IG484CirEY+40GTo= +github.com/nyaruka/phonenumbers v1.1.5/go.mod h1:yShPJHDSH3aTKzCbXyVxNpbl2kA+F+Ne5Pun/MvFRos= github.com/olivere/elastic/v7 v7.0.32 h1:R7CXvbu8Eq+WlsLgxmKVKPox0oOwAE/2T9Si5BnvK6E= github.com/olivere/elastic/v7 v7.0.32/go.mod h1:c7PVmLe3Fxq77PIfY/bZmxY/TAamBhCzZ8xDOE09a9k= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= -github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -70,18 +69,21 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 h1:yZNXmy+j/JpX19vZkVktWqAo7Gny4PBWYYK3zskGpx4= -golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= +golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 h1:BEABXpNXLEz0WxtA+6CQIz2xkg80e+1zrhWyMcq8VzE= +golang.org/x/exp v0.0.0-20230131160201-f062dba9d201/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= +golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= +golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= +golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= @@ -91,15 +93,12 @@ google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= -gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M= -gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/mail.v2 v2.3.1 h1:WYFn/oANrAGP2C0dcV6/pbkPzv8yGzqTjPmTeO7qoXk= gopkg.in/mail.v2 v2.3.1/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/utils/validator.go b/utils/validator.go index ae3d8cf15..a62832e22 100644 --- a/utils/validator.go +++ b/utils/validator.go @@ -6,10 +6,9 @@ import ( "reflect" "strings" + "github.com/go-playground/validator/v10" "github.com/nyaruka/gocommon/jsonx" - "github.com/pkg/errors" - "gopkg.in/go-playground/validator.v9" ) // our system validator, it can be shared across threads @@ -92,7 +91,6 @@ func (e ValidationErrors) Error() string { // field // // For example: "field 'flows' is required" -// func Validate(obj interface{}) error { var err error diff --git a/utils/validator_test.go b/utils/validator_test.go index 32e45150d..7b6ac4aa6 100644 --- a/utils/validator_test.go +++ b/utils/validator_test.go @@ -6,11 +6,10 @@ import ( "strings" "testing" + "github.com/go-playground/validator/v10" _ "github.com/nyaruka/goflow/envs" _ "github.com/nyaruka/goflow/flows" "github.com/nyaruka/goflow/utils" - "gopkg.in/go-playground/validator.v9" - "github.com/stretchr/testify/assert" )