Skip to content

Commit

Permalink
Merge pull request #274 from franmomu/contraint_attr
Browse files Browse the repository at this point in the history
Allow to use constraints as PHP 8 attributes
  • Loading branch information
excelwebzone committed Apr 8, 2022
2 parents e079503 + a1e5c6b commit da74e94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Validator/Constraints/IsTrue.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@
* @Annotation
* @Target("PROPERTY")
*/
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::IS_REPEATABLE)]
class IsTrue extends Constraint
{
public $message = 'This value is not a valid captcha.';

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

public function __construct(array $options = null, string $message = null, string invalidHostMessage = null, array $groups = null, $payload = null)
{
parent::__construct($options ?? [], $groups, $payload);

$this->message = $message ?? $this->message;
$this->invalidHostMessage = $invalidHostMessage ?? $this->invalidHostMessage;
}

/**
* {@inheritdoc}
*/
Expand Down
1 change: 1 addition & 0 deletions src/Validator/Constraints/IsTrueV3.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @Annotation
* @Target("PROPERTY")
*/
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::IS_REPEATABLE)]
class IsTrueV3 extends IsTrue
{
/**
Expand Down

0 comments on commit da74e94

Please sign in to comment.