TextUnmarshaler binds parameter to destination implementing encoding.TextUnmarshaler interface
(sourceParam string, dest encoding.TextUnmarshaler)
| 383 | |
| 384 | // TextUnmarshaler binds parameter to destination implementing encoding.TextUnmarshaler interface |
| 385 | func (b *ValueBinder) TextUnmarshaler(sourceParam string, dest encoding.TextUnmarshaler) *ValueBinder { |
| 386 | if b.failFast && b.errors != nil { |
| 387 | return b |
| 388 | } |
| 389 | |
| 390 | tmp := b.ValueFunc(sourceParam) |
| 391 | if tmp == "" { |
| 392 | return b |
| 393 | } |
| 394 | |
| 395 | if err := dest.UnmarshalText([]byte(tmp)); err != nil { |
| 396 | b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to encoding.TextUnmarshaler interface", err)) |
| 397 | } |
| 398 | return b |
| 399 | } |
| 400 | |
| 401 | // MustTextUnmarshaler requires parameter value to exist to bind to destination implementing encoding.TextUnmarshaler interface. |
| 402 | // Returns error when value does not exist |