Skip to content

Commit 8962494

Browse files
committed
TASK: Add custom validator not found message
1 parent 42680a9 commit 8962494

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Rule/ValidatorResolverOptionsRule.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,15 @@ public function processNode(Node $node, Scope $scope): array
6969
try {
7070
$validatorClassName = $this->validatorClassNameResolver->resolve($validatorType);
7171
} catch (\TYPO3\CMS\Extbase\Validation\Exception\NoSuchValidatorException $e) {
72+
if ($validatorType instanceof ConstantStringType) {
73+
$validatorClassName = $validatorType->getValue();
74+
$message = sprintf('Could not create validator for "%s"', $validatorClassName);
75+
} else {
76+
$message = 'Could not create validator';
77+
}
78+
7279
return [
73-
RuleErrorBuilder::message($e->getMessage())->build(),
80+
RuleErrorBuilder::message($message)->build(),
7481
];
7582
}
7683

tests/Unit/Rule/ValidatorResolverOptionsRule/ValidatorResolverOptionsRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function provideDataWithErrors(): \Iterator
3232
__DIR__ . '/Fixture/CreateValidatorWithUnresolvableType.php',
3333
[
3434
[
35-
'Validator class TYPO3\CMS\Extbase\Validation\Validator\FooValidator does not exist', 13,
35+
'Could not create validator for "Foo"', 13,
3636
],
3737
],
3838
];

0 commit comments

Comments
 (0)