MCPcopy
hub / github.com/ory/kratos / AddMessage

Method AddMessage

ui/container/container.go:340–356  ·  view source on GitHub ↗

AddMessage adds the provided error, and if a non-empty names list is set, adds the error on the corresponding field.

(group node.UiNodeGroup, err *text.Message, setForFields ...string)

Source from the content-addressed store, hash-verified

338// AddMessage adds the provided error, and if a non-empty names list is set,
339// adds the error on the corresponding field.
340func (c *Container) AddMessage(group node.UiNodeGroup, err *text.Message, setForFields ...string) {
341 if !slices.ContainsFunc(setForFields, func(s string) bool { return strings.TrimSpace(s) != "" }) {
342 c.Messages = append(c.Messages, *err)
343 return
344 }
345
346 for _, name := range setForFields {
347 if ff := c.Nodes.Find(name); ff != nil {
348 ff.Messages = append(ff.Messages, *err)
349 continue
350 }
351
352 n := node.NewInputField(name, nil, node.DefaultGroup, node.InputAttributeTypeText)
353 n.Messages = text.Messages{*err}
354 c.Nodes = append(c.Nodes, n)
355 }
356}
357
358func (c *Container) Scan(value interface{}) error {
359 return sqlxx.JSONScan(c, value)

Callers 2

TestContainerFunction · 0.95
ParseErrorMethod · 0.95

Calls 2

NewInputFieldFunction · 0.92
FindMethod · 0.45

Tested by 1

TestContainerFunction · 0.76