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

Function MinLength

dsl/validation.go:365–382  ·  view source on GitHub ↗

MinLength adds a "minItems" validation to the attribute. See http://json-schema.org/latest/json-schema-validation.html#anchor45. Example: Attribute("map", MapOf(String, String), func() { MinLength(10) // min key-values in map Key(func() { MinLength(1) // min length of ma

(val int)

Source from the content-addressed store, hash-verified

363// })
364// })
365func MinLength(val int) {
366 if a, ok := eval.Current().(*expr.AttributeExpr); ok {
367 if a.Type != nil {
368 kind := a.Type.Kind()
369 if kind != expr.BytesKind &&
370 kind != expr.StringKind &&
371 kind != expr.ArrayKind &&
372 kind != expr.MapKind {
373 incompatibleAttributeType("minimum length", a.Type.Name(), "a string or an array")
374 return
375 }
376 }
377 if a.Validation == nil {
378 a.Validation = &expr.ValidationExpr{}
379 }
380 a.Validation.MinLength = &val
381 }
382}
383
384// MaxLength adds a "maxItems" validation to the attribute.
385// See http://json-schema.org/latest/json-schema-validation.html#anchor42.

Callers 10

result_dsls.goFile · 0.85
openapi_dsls.goFile · 0.85
payload_dsls.goFile · 0.85
dsls.goFile · 0.85
type_spec_test.goFile · 0.85

Calls 4

CurrentFunction · 0.92
KindMethod · 0.65
NameMethod · 0.65

Tested by 2