BindUnmarshaler binds parameter to destination implementing BindUnmarshaler interface
(sourceParam string, dest BindUnmarshaler)
| 311 | |
| 312 | // BindUnmarshaler binds parameter to destination implementing BindUnmarshaler interface |
| 313 | func (b *ValueBinder) BindUnmarshaler(sourceParam string, dest BindUnmarshaler) *ValueBinder { |
| 314 | if b.failFast && b.errors != nil { |
| 315 | return b |
| 316 | } |
| 317 | |
| 318 | tmp := b.ValueFunc(sourceParam) |
| 319 | if tmp == "" { |
| 320 | return b |
| 321 | } |
| 322 | |
| 323 | if err := dest.UnmarshalParam(tmp); err != nil { |
| 324 | b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to BindUnmarshaler interface", err)) |
| 325 | } |
| 326 | return b |
| 327 | } |
| 328 | |
| 329 | // MustBindUnmarshaler requires parameter value to exist to bind to destination implementing BindUnmarshaler interface. |
| 330 | // Returns error when value does not exist |