c47bbbe5d3
* 2.5: [Validator] use 2.5 API in LengthValidator fixed id for translations bumped Symfony version to 2.3.26 Dutch translation for invalid charset message German translation for invalid charset message Add a Slovenian translation for invalid charset message Add a Polish translation. Test lowest deps with latest 5.3 updated VERSION for 2.3.25 update CONTRIBUTORS for 2.3.25 updated CHANGELOG for 2.3.25 Fix docblocks to comments Inject the correct EventDispatcher instance [Validator] reject ill-formed strings [Validator] drop grapheme_strlen in LengthValidator Unique Entity Validator Invalid Value [FrameworkBundle][config] allow multiple fallback locales. Conflicts: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php src/Symfony/Component/Validator/Resources/translations/validators.de.xlf src/Symfony/Component/Validator/Resources/translations/validators.en.xlf src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf
59 lines
1.9 KiB
PHP
59 lines
1.9 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* 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\MissingOptionsException;
|
|
|
|
/**
|
|
* @Annotation
|
|
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
|
|
*
|
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
|
*
|
|
* @api
|
|
*/
|
|
class Length extends Constraint
|
|
{
|
|
const TOO_SHORT_ERROR = 1;
|
|
const TOO_LONG_ERROR = 2;
|
|
|
|
protected static $errorNames = array(
|
|
self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR',
|
|
self::TOO_LONG_ERROR => 'TOO_LONG_ERROR',
|
|
);
|
|
|
|
public $maxMessage = 'This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.';
|
|
public $minMessage = 'This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.';
|
|
public $exactMessage = 'This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters.';
|
|
public $charsetMessage = 'This value does not match the expected {{ charset }} charset.';
|
|
public $max;
|
|
public $min;
|
|
public $charset = 'UTF-8';
|
|
|
|
public function __construct($options = null)
|
|
{
|
|
if (null !== $options && !is_array($options)) {
|
|
$options = array(
|
|
'min' => $options,
|
|
'max' => $options,
|
|
);
|
|
}
|
|
|
|
parent::__construct($options);
|
|
|
|
if (null === $this->min && null === $this->max) {
|
|
throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s', __CLASS__), array('min', 'max'));
|
|
}
|
|
}
|
|
}
|