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

Method MustBindUnmarshaler

binder.go:331–346  ·  view source on GitHub ↗

MustBindUnmarshaler requires parameter value to exist to bind to destination implementing BindUnmarshaler interface. Returns error when value does not exist

(sourceParam string, dest BindUnmarshaler)

Source from the content-addressed store, hash-verified

329// MustBindUnmarshaler requires parameter value to exist to bind to destination implementing BindUnmarshaler interface.
330// Returns error when value does not exist
331func (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
349func (b *ValueBinder) JSONUnmarshaler(sourceParam string, dest json.Unmarshaler) *ValueBinder {

Callers 1

Calls 2

setErrorMethod · 0.95
UnmarshalParamMethod · 0.65

Tested by 1