File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,21 @@ func (v valuer) Value() (sql.Value, error) {
170170 return v.Name , nil
171171}
172172
173+ // ValidateValuerType implements validator.CustomTypeFunc
174+ func ValidateValuerType (field reflect .Value ) interface {} {
175+ if valuer , ok := field.Interface ().(sql.Valuer ); ok {
176+ val , err := valuer.Value ()
177+ if err != nil {
178+ // handle the error how you want
179+ return nil
180+ }
181+
182+ return val
183+ }
184+
185+ return nil
186+ }
187+
173188func main () {
174189
175190 customTypes := map [reflect.Type ]validator.CustomTypeFunc {}
Original file line number Diff line number Diff line change @@ -118,6 +118,21 @@ func (v valuer) Value() (sql.Value, error) {
118118 return v .Name , nil
119119}
120120
121+ // ValidateValuerType implements validator.CustomTypeFunc
122+ func ValidateValuerType (field reflect.Value ) interface {} {
123+ if valuer , ok := field .Interface ().(sql.Valuer ); ok {
124+ val , err := valuer .Value ()
125+ if err != nil {
126+ // handle the error how you want
127+ return nil
128+ }
129+
130+ return val
131+ }
132+
133+ return nil
134+ }
135+
121136func main2 () {
122137
123138 customTypes := map [reflect.Type ]validator.CustomTypeFunc {}
You can’t perform that action at this time.
0 commit comments