AbstractComparison.php
1 year ago
AbstractComparisonValidator.php
1 year ago
All.php
1 year ago
AllValidator.php
4 years ago
AtLeastOneOf.php
1 year ago
AtLeastOneOfValidator.php
1 year ago
Bic.php
1 year ago
BicValidator.php
1 year ago
Blank.php
1 year ago
BlankValidator.php
4 years ago
Callback.php
1 year ago
CallbackValidator.php
4 years ago
CardScheme.php
1 year ago
CardSchemeValidator.php
1 year ago
Cascade.php
1 year ago
Choice.php
1 year ago
ChoiceValidator.php
1 year ago
Cidr.php
1 year ago
CidrValidator.php
4 years ago
Collection.php
1 year ago
CollectionValidator.php
4 years ago
Composite.php
1 year ago
Compound.php
4 years ago
CompoundValidator.php
4 years ago
Count.php
1 year ago
CountValidator.php
4 years ago
Country.php
1 year ago
CountryValidator.php
4 years ago
CssColor.php
1 year ago
CssColorValidator.php
1 year ago
Currency.php
1 year ago
CurrencyValidator.php
4 years ago
Date.php
1 year ago
DateTime.php
1 year ago
DateTimeValidator.php
2 years ago
DateValidator.php
1 year ago
DisableAutoMapping.php
1 year ago
DivisibleBy.php
4 years ago
DivisibleByValidator.php
4 years ago
Email.php
1 year ago
EmailValidator.php
1 year ago
EnableAutoMapping.php
1 year ago
EqualTo.php
4 years ago
EqualToValidator.php
4 years ago
Existence.php
4 years ago
Expression.php
1 year ago
ExpressionLanguageSyntax.php
1 year ago
ExpressionLanguageSyntaxValidator.php
1 year ago
ExpressionValidator.php
1 year ago
File.php
1 year ago
FileValidator.php
4 years ago
GreaterThan.php
4 years ago
GreaterThanOrEqual.php
4 years ago
GreaterThanOrEqualValidator.php
4 years ago
GreaterThanValidator.php
4 years ago
GroupSequence.php
4 years ago
GroupSequenceProvider.php
4 years ago
Hostname.php
1 year ago
HostnameValidator.php
4 years ago
Iban.php
1 year ago
IbanValidator.php
1 year ago
IdenticalTo.php
4 years ago
IdenticalToValidator.php
4 years ago
Image.php
1 year ago
ImageValidator.php
4 years ago
Ip.php
1 year ago
IpValidator.php
4 years ago
IsFalse.php
1 year ago
IsFalseValidator.php
4 years ago
IsNull.php
1 year ago
IsNullValidator.php
4 years ago
IsTrue.php
1 year ago
IsTrueValidator.php
4 years ago
Isbn.php
1 year ago
IsbnValidator.php
1 year ago
Isin.php
1 year ago
IsinValidator.php
4 years ago
Issn.php
1 year ago
IssnValidator.php
4 years ago
Json.php
1 year ago
JsonValidator.php
1 year ago
Language.php
1 year ago
LanguageValidator.php
4 years ago
Length.php
1 year ago
LengthValidator.php
4 years ago
LessThan.php
4 years ago
LessThanOrEqual.php
4 years ago
LessThanOrEqualValidator.php
4 years ago
LessThanValidator.php
4 years ago
Locale.php
1 year ago
LocaleValidator.php
4 years ago
Luhn.php
1 year ago
LuhnValidator.php
4 years ago
Negative.php
4 years ago
NegativeOrZero.php
4 years ago
NotBlank.php
1 year ago
NotBlankValidator.php
4 years ago
NotCompromisedPassword.php
1 year ago
NotCompromisedPasswordValidator.php
1 year ago
NotEqualTo.php
4 years ago
NotEqualToValidator.php
4 years ago
NotIdenticalTo.php
4 years ago
NotIdenticalToValidator.php
4 years ago
NotNull.php
1 year ago
NotNullValidator.php
4 years ago
NumberConstraintTrait.php
4 years ago
Optional.php
4 years ago
Positive.php
4 years ago
PositiveOrZero.php
4 years ago
Range.php
1 year ago
RangeValidator.php
1 year ago
Regex.php
1 year ago
RegexValidator.php
4 years ago
Required.php
4 years ago
Sequentially.php
1 year ago
SequentiallyValidator.php
4 years ago
Time.php
1 year ago
TimeValidator.php
1 year ago
Timezone.php
1 year ago
TimezoneValidator.php
1 year ago
Traverse.php
4 years ago
Type.php
1 year ago
TypeValidator.php
4 years ago
Ulid.php
1 year ago
UlidValidator.php
2 years ago
Unique.php
1 year ago
UniqueValidator.php
1 year ago
Url.php
1 year ago
UrlValidator.php
1 year ago
Uuid.php
1 year ago
UuidValidator.php
4 years ago
Valid.php
1 year ago
ValidValidator.php
4 years ago
ZeroComparisonConstraintTrait.php
1 year ago
index.php
3 years ago
Length.php
56 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\Validator\Constraints; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Symfony\Component\Validator\Constraint; |
| 5 | use MailPoetVendor\Symfony\Component\Validator\Exception\InvalidArgumentException; |
| 6 | use MailPoetVendor\Symfony\Component\Validator\Exception\MissingOptionsException; |
| 7 | #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] |
| 8 | class Length extends Constraint |
| 9 | { |
| 10 | public const TOO_SHORT_ERROR = '9ff3fdc4-b214-49db-8718-39c315e33d45'; |
| 11 | public const TOO_LONG_ERROR = 'd94b19cc-114f-4f44-9cc4-4138e80a87b9'; |
| 12 | public const NOT_EQUAL_LENGTH_ERROR = '4b6f5c76-22b4-409d-af16-fbe823ba9332'; |
| 13 | public const INVALID_CHARACTERS_ERROR = '35e6a710-aa2e-4719-b58e-24b35749b767'; |
| 14 | protected static $errorNames = [self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR', self::TOO_LONG_ERROR => 'TOO_LONG_ERROR', self::NOT_EQUAL_LENGTH_ERROR => 'NOT_EQUAL_LENGTH_ERROR', self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR']; |
| 15 | 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.'; |
| 16 | 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.'; |
| 17 | public $exactMessage = 'This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters.'; |
| 18 | public $charsetMessage = 'This value does not match the expected {{ charset }} charset.'; |
| 19 | public $max; |
| 20 | public $min; |
| 21 | public $charset = 'UTF-8'; |
| 22 | public $normalizer; |
| 23 | public $allowEmptyString = \false; |
| 24 | public function __construct($exactly = null, ?int $min = null, ?int $max = null, ?string $charset = null, ?callable $normalizer = null, ?string $exactMessage = null, ?string $minMessage = null, ?string $maxMessage = null, ?string $charsetMessage = null, ?array $groups = null, $payload = null, array $options = []) |
| 25 | { |
| 26 | if (\is_array($exactly)) { |
| 27 | $options = \array_merge($exactly, $options); |
| 28 | $exactly = $options['value'] ?? null; |
| 29 | } |
| 30 | $min = $min ?? $options['min'] ?? null; |
| 31 | $max = $max ?? $options['max'] ?? null; |
| 32 | unset($options['value'], $options['min'], $options['max']); |
| 33 | if (null !== $exactly && null === $min && null === $max) { |
| 34 | $min = $max = $exactly; |
| 35 | } |
| 36 | parent::__construct($options, $groups, $payload); |
| 37 | $this->min = $min; |
| 38 | $this->max = $max; |
| 39 | $this->charset = $charset ?? $this->charset; |
| 40 | $this->normalizer = $normalizer ?? $this->normalizer; |
| 41 | $this->exactMessage = $exactMessage ?? $this->exactMessage; |
| 42 | $this->minMessage = $minMessage ?? $this->minMessage; |
| 43 | $this->maxMessage = $maxMessage ?? $this->maxMessage; |
| 44 | $this->charsetMessage = $charsetMessage ?? $this->charsetMessage; |
| 45 | if (null === $this->min && null === $this->max) { |
| 46 | throw new MissingOptionsException(\sprintf('Either option "min" or "max" must be given for constraint "%s".', __CLASS__), ['min', 'max']); |
| 47 | } |
| 48 | if (null !== $this->normalizer && !\is_callable($this->normalizer)) { |
| 49 | throw new InvalidArgumentException(\sprintf('The "normalizer" option must be a valid callable ("%s" given).', \get_debug_type($this->normalizer))); |
| 50 | } |
| 51 | if (isset($options['allowEmptyString'])) { |
| 52 | trigger_deprecation('symfony/validator', '5.2', \sprintf('The "allowEmptyString" option of the "%s" constraint is deprecated.', self::class)); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 |