-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Expand file tree
/
Copy pathIsTrue.php
More file actions
46 lines (37 loc) · 1.34 KB
/
IsTrue.php
File metadata and controls
46 lines (37 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\InvalidArgumentException;
/**
* Validates that a value is true.
*
* @author Bernhard Schussek <[email protected]>
*/
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class IsTrue extends Constraint
{
public const NOT_TRUE_ERROR = '2beabf1c-54c0-4882-a928-05249b26e23b';
protected const ERROR_NAMES = [
self::NOT_TRUE_ERROR => 'NOT_TRUE_ERROR',
];
public string $message = 'This value should be true.';
/**
* @param string[]|null $groups
*/
public function __construct(?array $options = null, ?string $message = null, ?array $groups = null, mixed $payload = null)
{
if (null !== $options) {
throw new InvalidArgumentException(\sprintf('Passing an array of options to configure the "%s" constraint is no longer supported.', static::class));
}
parent::__construct(null, $groups, $payload);
$this->message = $message ?? $this->message;
}
}