MCPcopy Create free account
hub / github.com/goadesign/goa / Key

Function Key

dsl/user_type.go:261–272  ·  view source on GitHub ↗

Key makes it possible to specify validations for map keys. Example: Attribute("map", MapOf(String, Int), func() { Key(func() { Format(FormatDateTime) // map keys are timestamps }) })

(fn func())

Source from the content-addressed store, hash-verified

259// })
260// })
261func Key(fn func()) {
262 at, ok := eval.Current().(*expr.AttributeExpr)
263 if !ok {
264 eval.IncompatibleDSL()
265 return
266 }
267 if m, ok := at.Type.(*expr.Map); ok {
268 eval.Execute(fn, m.KeyType)
269 return
270 }
271 eval.IncompatibleDSL()
272}
273
274// Elem makes it possible to specify validations for array and map values.
275//

Callers 5

TestGetMetaTypeImportsFunction · 0.92
openapi_dsls.goFile · 0.85
payload_dsls.goFile · 0.85
type_spec_test.goFile · 0.85

Calls 3

CurrentFunction · 0.92
IncompatibleDSLFunction · 0.92
ExecuteFunction · 0.92

Tested by 1

TestGetMetaTypeImportsFunction · 0.74