annotate vendor/symfony/validator/Constraints/Count.php @ 8:50b0d041100e

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