[php-symfony] remove nested Valid constraint (#8994)

* Fix constraint Valid cannot be nested

* Update PetController.php

* Update UserController.php
This commit is contained in:
vnq
2021-03-24 06:30:42 +01:00
committed by GitHub
parent f137f3331a
commit 74e5c3ccd3
3 changed files with 7 additions and 5 deletions

View File

@@ -19,11 +19,11 @@
{{#items}} {{#items}}
$asserts[] = new Assert\All([ $asserts[] = new Assert\All([
new Assert\Type("{{dataType}}"), new Assert\Type("{{dataType}}"),
{{^isPrimitiveType}}
new Assert\Valid(),
{{/isPrimitiveType}}
]); ]);
{{/items}} {{/items}}
{{^isPrimitiveType}}
$asserts[] = new Assert\Valid();
{{/isPrimitiveType}}
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
{{#isDate}} {{#isDate}}

View File

@@ -257,6 +257,7 @@ class PetController extends Controller
$asserts[] = new Assert\All([ $asserts[] = new Assert\All([
new Assert\Type("string"), new Assert\Type("string"),
]); ]);
$asserts[] = new Assert\Valid();
$response = $this->validate($status, $asserts); $response = $this->validate($status, $asserts);
if ($response instanceof Response) { if ($response instanceof Response) {
return $response; return $response;
@@ -345,6 +346,7 @@ class PetController extends Controller
$asserts[] = new Assert\All([ $asserts[] = new Assert\All([
new Assert\Type("string"), new Assert\Type("string"),
]); ]);
$asserts[] = new Assert\Valid();
$response = $this->validate($tags, $asserts); $response = $this->validate($tags, $asserts);
if ($response instanceof Response) { if ($response instanceof Response) {
return $response; return $response;

View File

@@ -163,8 +163,8 @@ class UserController extends Controller
$asserts[] = new Assert\NotNull(); $asserts[] = new Assert\NotNull();
$asserts[] = new Assert\All([ $asserts[] = new Assert\All([
new Assert\Type("OpenAPI\Server\Model\User"), new Assert\Type("OpenAPI\Server\Model\User"),
new Assert\Valid(),
]); ]);
$asserts[] = new Assert\Valid();
$response = $this->validate($body, $asserts); $response = $this->validate($body, $asserts);
if ($response instanceof Response) { if ($response instanceof Response) {
return $response; return $response;
@@ -242,8 +242,8 @@ class UserController extends Controller
$asserts[] = new Assert\NotNull(); $asserts[] = new Assert\NotNull();
$asserts[] = new Assert\All([ $asserts[] = new Assert\All([
new Assert\Type("OpenAPI\Server\Model\User"), new Assert\Type("OpenAPI\Server\Model\User"),
new Assert\Valid(),
]); ]);
$asserts[] = new Assert\Valid();
$response = $this->validate($body, $asserts); $response = $this->validate($body, $asserts);
if ($response instanceof Response) { if ($response instanceof Response) {
return $response; return $response;