Skip to content

Commit

Permalink
Allow using validation constraint as PHP8 attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
norkunas authored and karser committed Jan 10, 2022
1 parent 8d962a3 commit 5139502
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Validator/Constraints/Recaptcha3.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

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

public $message = 'Your computer or network may be sending automated queries';
public $messageMissingValue = 'The captcha value is missing';

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

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

0 comments on commit 5139502

Please sign in to comment.