Skip to content

Commit 5139502

Browse files
norkunaskarser
authored andcommitted
Allow using validation constraint as PHP8 attribute
1 parent 8d962a3 commit 5139502

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Validator/Constraints/Recaptcha3.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
/**
88
* @Annotation
9+
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
910
*/
11+
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
1012
final class Recaptcha3 extends Constraint
1113
{
1214
const INVALID_FORMAT_ERROR = '7147ffdb-0af4-4f7a-bd5e-e9dcfa6d7a2d';
@@ -17,4 +19,12 @@ final class Recaptcha3 extends Constraint
1719

1820
public $message = 'Your computer or network may be sending automated queries';
1921
public $messageMissingValue = 'The captcha value is missing';
22+
23+
public function __construct(?array $options = null, ?string $message = null, ?string $messageMissingValue = null, ?array $groups = null, $payload = null)
24+
{
25+
parent::__construct($options ?? [], $groups, $payload);
26+
27+
$this->message = $message ?? $this->message;
28+
$this->messageMissingValue = $messageMissingValue ?? $this->messageMissingValue;
29+
}
2030
}

0 commit comments

Comments
 (0)