The StasPlovDtoValidatorBundle Validating the Request by DTO in the context of symfony.
The core idea of StasPlovDtoValidatorBundle is to validate input data in the controller from the Request using so-called DTO (Data Transfer Object) entities.
#[ValidateDto(class: CreateDto::class)]
#[Route(path: '/create/user', name: 'api-user-create', methods: ['POST'])]
public function createUser(CreateDto $createDto): Response {
// ... some code
}
The $createDto
variable will contain all the data described in the corresponding CreateDto
class.
Require the stas-plov/dto-validator-bundle
package in your composer.json and update your dependencies:
composer require stas-plov/dto-validator-bundle
Flex, you'll need to enable it manually as explained in the docs.
See the documentation for usage instructions.
Released under the MIT License, see LICENSE.