File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
src/Core/Mapping/Validator Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -250,6 +250,7 @@ services:
250250 - setConstraintValidatorFactory(Contributte\Validator\ContainerConstraintValidatorFactory())
251251 - setTranslator(@Contributte\Translation\Translator)
252252 - setTranslationDomain('validators')
253+ - setGroups(['input'])
253254api :
254255 plugins :
255256 Apitte\Core\DI\Plugin\CoreMappingPlugin :
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ class SymfonyValidator implements IEntityValidator
2121
2222 private ?string $ translationDomain = null ;
2323
24+ private ?array $ groups = null ;
25+
2426 public function __construct (?Reader $ reader = null )
2527 {
2628 $ this ->reader = $ reader ;
@@ -42,6 +44,11 @@ public function setTranslationDomain(string $translationDomain): void
4244 $ this ->translationDomain = $ translationDomain ;
4345 }
4446
47+ public function setGroups (array $ groups ): void
48+ {
49+ $ this ->groups = $ groups ;
50+ }
51+
4552 /**
4653 * @throws ValidationException
4754 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
@@ -67,7 +74,7 @@ public function validate(object $entity): void
6774 $ validator = $ validatorBuilder ->getValidator ();
6875
6976 /** @var ConstraintViolationListInterface $violations */
70- $ violations = $ validator ->validate ($ entity );
77+ $ violations = $ validator ->validate ($ entity, null , $ this -> groups );
7178
7279 if (count ($ violations ) > 0 ) {
7380 $ fields = [];
You can’t perform that action at this time.
0 commit comments