8000 Raise a meaningful exception if the YAML component is not installed · symfonyaml/symfony@13881b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 13881b6

Browse files
author
symfonyaml
committed
Raise a meaningful exception if the YAML component is not installed
1 parent 1afdc18 commit 13881b6

File tree

1 file changed

+6
-0
lines changed
  • src/Symfony/Component/Validator/Constraints

1 file changed

+6
-0
lines changed

src/Symfony/Component/Validator/Constraints/Yaml.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\Validator\Constraints;
1313

1414
use Symfony\Component\Validator\Constraint;
15+
use Symfony\Component\Validator\Exception\LogicException;
16+
use Symfony\Component\Yaml\Parser;
1517

1618
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
1719
class Yaml extends Constraint
@@ -28,6 +30,10 @@ public function __construct(
2830
?array $groups = null,
2931
mixed $payload = null,
3032
) {
33+
if (!class_exists(Parser::class)) {
34+
throw new LogicException('The Yaml component is required to use the Yaml constraint. Try running "composer require symfony/yaml".');
35+
}
36+
3137
parent::__construct(null, $groups, $payload);
3238
}
3339
}

0 commit comments

Comments
 (0)
0