MCPcopy Create free account
hub / github.com/gotenberg/gotenberg / Custom

Method Custom

pkg/modules/api/formdata.go:270–282  ·  view source on GitHub ↗

Custom helps to define a custom binding function for a form field. var foo map[string]string ctx.FormData().Custom("foo", func(value string) error { if value == "" { foo = "bar" return nil } err := json.Unmarshal([]byte(value), &foo) if err != nil { return fmt.Errorf

(key string, assign func(value string) error)

Source from the content-addressed store, hash-verified

268// return nil
269// })
270func (form *FormData) Custom(key string, assign func(value string) error) *FormData {
271 var value string
272 form.mustValue(key, &value, "")
273
274 err := assign(value)
275 if err != nil {
276 form.append(
277 fmt.Errorf("form field '%s' is invalid (got '%s', resulting to %w)", key, value, err),
278 )
279 }
280
281 return form
282}
283
284// MandatoryCustom helps to define a custom binding function for a form field.
285// It populates an error if the value is empty or the "key" does not exist.

Callers 10

TestFormData_CustomFunction · 0.80
FormDataPdfSplitModeFunction · 0.80
FormDataPdfMetadataFunction · 0.80
FormDataPdfBookmarksFunction · 0.80
FormDataPdfRotateFunction · 0.80
FormDataPdfFacturXFunction · 0.80
FormDataChromiumOptionsFunction · 0.80
convertRouteFunction · 0.80

Calls 2

mustValueMethod · 0.95
appendMethod · 0.95

Tested by 1

TestFormData_CustomFunction · 0.64