MustTextUnmarshaler requires parameter value to exist to bind to destination implementing encoding.TextUnmarshaler interface. Returns error when value does not exist
(sourceParam string, dest encoding.TextUnmarshaler)
| 401 | // MustTextUnmarshaler requires parameter value to exist to bind to destination implementing encoding.TextUnmarshaler interface. |
| 402 | // Returns error when value does not exist |
| 403 | func (b *ValueBinder) MustTextUnmarshaler(sourceParam string, dest encoding.TextUnmarshaler) *ValueBinder { |
| 404 | if b.failFast && b.errors != nil { |
| 405 | return b |
| 406 | } |
| 407 | |
| 408 | tmp := b.ValueFunc(sourceParam) |
| 409 | if tmp == "" { |
| 410 | b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "required field value is empty", nil)) |
| 411 | return b |
| 412 | } |
| 413 | |
| 414 | if err := dest.UnmarshalText([]byte(tmp)); err != nil { |
| 415 | b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to encoding.TextUnmarshaler interface", err)) |
| 416 | } |
| 417 | return b |
| 418 | } |
| 419 | |
| 420 | // BindWithDelimiter binds parameter to destination by suitable conversion function. |
| 421 | // Delimiter is used before conversion to split parameter value to separate values |