diff --git a/baked_in.go b/baked_in.go index 2f66c183..fdefdd9b 100644 --- a/baked_in.go +++ b/baked_in.go @@ -24,6 +24,7 @@ import ( "github.com/gabriel-vasile/mimetype" urn "github.com/leodido/go-urn" + "github.com/lib/pq" ) // Func accepts a FieldLevel interface for all validation needs. The return @@ -326,6 +327,11 @@ func isUnique(fl FieldLevel) bool { switch field.Kind() { case reflect.Slice, reflect.Array: + // If it's a pq.StringArray, convert it to a []string for easier handling + if field.Type() == reflect.TypeOf(pq.StringArray{}) { + field = reflect.ValueOf([]string(field.Interface().(pq.StringArray))) + } + elem := field.Type().Elem() if elem.Kind() == reflect.Ptr { elem = elem.Elem() diff --git a/go.mod b/go.mod index c77643fc..2125684e 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/go-playground/locales v0.14.1 github.com/go-playground/universal-translator v0.18.1 github.com/leodido/go-urn v1.4.0 + github.com/lib/pq v1.10.9 golang.org/x/crypto v0.19.0 golang.org/x/text v0.14.0 ) diff --git a/go.sum b/go.sum index 3bf8a6e6..15d4d035 100644 --- a/go.sum +++ b/go.sum @@ -9,6 +9,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=