MustBindUnmarshaler requires parameter value to exist to bind to destination implementing BindUnmarshaler interface. Returns error when value does not exist
(sourceParam string, dest BindUnmarshaler)
| 329 | // MustBindUnmarshaler requires parameter value to exist to bind to destination implementing BindUnmarshaler interface. |
| 330 | // Returns error when value does not exist |
| 331 | func (b *ValueBinder) MustBindUnmarshaler(sourceParam string, dest BindUnmarshaler) *ValueBinder { |
| 332 | if b.failFast && b.errors != nil { |
| 333 | return b |
| 334 | } |
| 335 | |
| 336 | value := b.ValueFunc(sourceParam) |
| 337 | if value == "" { |
| 338 | b.setError(b.ErrorFunc(sourceParam, []string{value}, "required field value is empty", nil)) |
| 339 | return b |
| 340 | } |
| 341 | |
| 342 | if err := dest.UnmarshalParam(value); err != nil { |
| 343 | b.setError(b.ErrorFunc(sourceParam, []string{value}, "failed to bind field value to BindUnmarshaler interface", err)) |
| 344 | } |
| 345 | return b |
| 346 | } |
| 347 | |
| 348 | // JSONUnmarshaler binds parameter to destination implementing json.Unmarshaler interface |
| 349 | func (b *ValueBinder) JSONUnmarshaler(sourceParam string, dest json.Unmarshaler) *ValueBinder { |