Skip to content

Commit 190e5bb

Browse files
throw exception if using , add arguments for all options
1 parent 5ce29c3 commit 190e5bb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Validator/Constraints/VatNumber.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Ibericode\Vat\Bundle\Validator\Constraints;
44

55
use Symfony\Component\Validator\Constraint;
6+
use Symfony\Component\Validator\Exception\InvalidArgumentException;
67

78
#[\Attribute(\Attribute::TARGET_PROPERTY)]
89
class VatNumber extends Constraint
@@ -16,11 +17,16 @@ class VatNumber extends Constraint
1617
public bool $checkExistence = true;
1718
public bool $violateOnException = false;
1819

19-
#[HasNamedArguments]
20-
public function __construct(?string $message = null, ?array $groups = null, mixed $payload = null)
20+
public function __construct(?array $options = null, ?string $message = null, ?array $groups = null, mixed $payload = null, ?bool $checkExistence = null, ?bool $violateOnException = null)
2121
{
22+
if (null !== $options) {
23+
throw new InvalidArgumentException(\sprintf('Passing an array of options to configure the "%s" constraint is no longer supported.', static::class));
24+
}
25+
2226
parent::__construct(null, $groups, $payload);
2327

2428
$this->message = $message ?? $this->message;
29+
$this->checkExistence = $checkExistence ?? $this->checkExistence;
30+
$this->violateOnException = $violateOnException ?? $this->violateOnException;
2531
}
2632
}

0 commit comments

Comments
 (0)