Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / validator / Constraints / Count.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Validator\Constraints;
13
14 use Symfony\Component\Validator\Constraint;
15 use Symfony\Component\Validator\Exception\MissingOptionsException;
16
17 /**
18  * @Annotation
19  * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
20  *
21  * @author Bernhard Schussek <bschussek@gmail.com>
22  */
23 class Count extends Constraint
24 {
25     const TOO_FEW_ERROR = 'bef8e338-6ae5-4caf-b8e2-50e7b0579e69';
26     const TOO_MANY_ERROR = '756b1212-697c-468d-a9ad-50dd783bb169';
27
28     protected static $errorNames = array(
29         self::TOO_FEW_ERROR => 'TOO_FEW_ERROR',
30         self::TOO_MANY_ERROR => 'TOO_MANY_ERROR',
31     );
32
33     public $minMessage = 'This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more.';
34     public $maxMessage = 'This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less.';
35     public $exactMessage = 'This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements.';
36     public $min;
37     public $max;
38
39     public function __construct($options = null)
40     {
41         if (null !== $options && !is_array($options)) {
42             $options = array(
43                 'min' => $options,
44                 'max' => $options,
45             );
46         }
47
48         parent::__construct($options);
49
50         if (null === $this->min && null === $this->max) {
51             throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s', __CLASS__), array('min', 'max'));
52         }
53     }
54 }