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

Function byEnum

expr/example.go:185–193  ·  view source on GitHub ↗

byEnum returns a random selected enum value.

(a *AttributeExpr, r *ExampleGenerator)

Source from the content-addressed store, hash-verified

183
184// byEnum returns a random selected enum value.
185func byEnum(a *AttributeExpr, r *ExampleGenerator) any {
186 if !hasEnumValidation(a) {
187 return nil
188 }
189 values := a.Validation.Values
190 count := len(values)
191 i := r.Int() % count
192 return values[i]
193}
194
195// byFormat returns a random example based on the format the user asks.
196func byFormat(a *AttributeExpr, r *ExampleGenerator) any {

Callers 1

ExampleMethod · 0.85

Calls 2

hasEnumValidationFunction · 0.85
IntMethod · 0.65

Tested by

no test coverage detected