@@ -32,6 +32,7 @@ func TestServerTypes(t *testing.T) {
32
32
{"server-query-custom-name" , testdata .PayloadQueryCustomNameDSL , QueryCustomNameServerTypesFile },
33
33
{"server-header-custom-name" , testdata .PayloadHeaderCustomNameDSL , HeaderCustomNameServerTypesFile },
34
34
{"server-cookie-custom-name" , testdata .PayloadCookieCustomNameDSL , CookieCustomNameServerTypesFile },
35
+ {"server-payload-with-validated-alias" , testdata .PayloadWithValidatedAliasDSL , PayloadWithValidatedAliasServerTypeCode },
35
36
}
36
37
for _ , c := range cases {
37
38
t .Run (c .Name , func (t * testing.T ) {
@@ -380,3 +381,39 @@ func NewMethodCookieCustomNamePayload(c2 *string) *servicecookiecustomname.Metho
380
381
return v
381
382
}
382
383
`
384
+
385
+ const PayloadWithValidatedAliasServerTypeCode = `// MethodStreamingBody is the type of the "ServicePayloadValidatedAlias"
386
+ // service "Method" endpoint HTTP request body.
387
+ type MethodStreamingBody struct {
388
+ Name *ValidatedStringStreamingBody ` + "`" + `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"` + "`" + `
389
+ }
390
+
391
+ // ValidatedStringStreamingBody is used to define fields on request body types.
392
+ type ValidatedStringStreamingBody string
393
+
394
+ // NewMethodStreamingBody builds a ServicePayloadValidatedAlias service Method
395
+ // endpoint payload.
396
+ func NewMethodStreamingBody(body *MethodStreamingBody) *servicepayloadvalidatedalias.MethodStreamingPayload {
397
+ v := &servicepayloadvalidatedalias.MethodStreamingPayload{}
398
+ if body.Name != nil {
399
+ name := servicepayloadvalidatedalias.ValidatedString(*body.Name)
400
+ v.Name = &name
401
+ }
402
+
403
+ return v
404
+ }
405
+
406
+ // ValidateMethodStreamingBody runs the validations defined on
407
+ // MethodStreamingBody
408
+ func ValidateMethodStreamingBody(body *MethodStreamingBody) (err error) {
409
+ if body.Name != nil {
410
+ err = goa.MergeErrors(err, goa.ValidatePattern("body.name", string(*body.Name), "^[a-zA-Z]+$"))
411
+ }
412
+ if body.Name != nil {
413
+ if utf8.RuneCountInString(string(*body.Name)) < 10 {
414
+ err = goa.MergeErrors(err, goa.InvalidLengthError("body.name", string(*body.Name), utf8.RuneCountInString(string(*body.Name)), 10, true))
415
+ }
416
+ }
417
+ return
418
+ }
419
+ `
0 commit comments