-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from ingenerator/include-warden-symfony-validator
Include warden-validator-symfony as part of the core package
- Loading branch information
Showing
26 changed files
with
322 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* @author Andrew Coulton <andrew@ingenerator.com> | ||
* @licence proprietary | ||
*/ | ||
|
||
namespace Ingenerator\Warden\Core\Validator; | ||
|
||
use Symfony\Component\Validator\ConstraintViolationInterface; | ||
use Symfony\Component\Validator\Validator\ValidatorInterface; | ||
|
||
class SymfonyValidator implements Validator | ||
{ | ||
|
||
public function __construct(protected ValidatorInterface $validator) | ||
{ | ||
} | ||
|
||
public function validate($object): array | ||
{ | ||
$errors = $this->validator->validate($object); | ||
$error_messages = []; | ||
foreach ($errors as $error) { | ||
/** @var ConstraintViolationInterface $error */ | ||
$error_messages[$error->getPropertyPath()] = $error->getMessage(); | ||
} | ||
|
||
return $error_messages; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* @author Craig Gosman <craig@ingenerator.com> | ||
* @licence proprietary | ||
*/ | ||
|
||
namespace Ingenerator\Warden\Core\Validator; | ||
|
||
use Symfony\Component\Validator\Validation; | ||
|
||
class SymfonyValidatorFactory | ||
{ | ||
public static function factory(): SymfonyValidator | ||
{ | ||
$builder = Validation::createValidatorBuilder(); | ||
$builder->enableAttributeMapping(); | ||
|
||
return new SymfonyValidator($builder->getValidator()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.