Skip to content

Commit

Permalink
Use Symfony Validator service (OpenAPITools#2143)
Browse files Browse the repository at this point in the history
  • Loading branch information
ossinkine authored and ackintosh committed Feb 14, 2019
1 parent da08c72 commit 1f0c003
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
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

0 comments on commit 1f0c003

Please sign in to comment.