Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Commit da74e94

Browse files
authored
Merge pull request #274 from franmomu/contraint_attr
Allow to use constraints as PHP 8 attributes
2 parents e079503 + a1e5c6b commit da74e94

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/Validator/Constraints/IsTrue.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@
88
* @Annotation
99
* @Target("PROPERTY")
1010
*/
11+
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::IS_REPEATABLE)]
1112
class IsTrue extends Constraint
1213
{
1314
public $message = 'This value is not a valid captcha.';
1415

1516
public $invalidHostMessage = 'The captcha was not resolved on the right domain.';
1617

18+
public function __construct(array $options = null, string $message = null, string invalidHostMessage = null, array $groups = null, $payload = null)
19+
{
20+
parent::__construct($options ?? [], $groups, $payload);
21+
22+
$this->message = $message ?? $this->message;
23+
$this->invalidHostMessage = $invalidHostMessage ?? $this->invalidHostMessage;
24+
}
25+
1726
/**
1827
* {@inheritdoc}
1928
*/

src/Validator/Constraints/IsTrueV3.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @Annotation
77
* @Target("PROPERTY")
88
*/
9+
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::IS_REPEATABLE)]
910
class IsTrueV3 extends IsTrue
1011
{
1112
/**

0 commit comments

Comments
 (0)