Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use Symfony Validator service
  • Loading branch information
ossinkine committed Feb 13, 2019
commit be802271c6debdf69eba0d5f1d487b57eb64fe9b
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ services:

{{bundleAlias}}.service.validator:
class: '%{{bundleAlias}}.validator%'
arguments:
- '@validator'

{{#apiInfo}}
{{#apis}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace {{servicePackage}};

use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Validator\ValidatorInterface as SymfonyValidatorInterface;

class SymfonyValidator implements ValidatorInterface
{
protected $validator;

public function __construct()
public function __construct(SymfonyValidatorInterface $validator)
{
$this->validator = Validation::createValidator();
$this->validator = $validator;
}

public function validate($value, $constraints = null, $groups = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ services:

open_apiserver.service.validator:
class: '%open_apiserver.validator%'
arguments:
- '@validator'

open_apiserver.controller.pet:
class: OpenAPI\Server\Controller\PetController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace OpenAPI\Server\Service;

use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Validator\ValidatorInterface as SymfonyValidatorInterface;

class SymfonyValidator implements ValidatorInterface
{
protected $validator;

public function __construct()
public function __construct(SymfonyValidatorInterface $validator)
{
$this->validator = Validation::createValidator();
$this->validator = $validator;
}

public function validate($value, $constraints = null, $groups = null)
Expand Down