MCPcopy Index your code
hub / github.com/labstack/echo / MustTextUnmarshaler

Method MustTextUnmarshaler

binder.go:403–418  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

401// MustTextUnmarshaler requires parameter value to exist to bind to destination implementing encoding.TextUnmarshaler interface.
402// Returns error when value does not exist
403func (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

Callers 1

Calls 2

setErrorMethod · 0.95
UnmarshalTextMethod · 0.80

Tested by 1