Permalink
Browse files

[Validator] removed deprecated constraints

  • Loading branch information...
1 parent 4a70ddf commit 65e3b1684b7607c67cae69cb8e26779f0803d9b7 @fabpot fabpot committed Mar 1, 2013
@@ -1,51 +0,0 @@
-<?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;
-
-/**
- * @Annotation
- *
- * @api
- *
- * @deprecated Deprecated since version 2.1, to be removed in 2.3.
- */
-class Max extends Constraint
-{
- public $message = 'This value should be {{ limit }} or less.';
- public $invalidMessage = 'This value should be a valid number.';
- public $limit;
-
- public function __construct($options = null)
- {
- trigger_error('Max is deprecated since version 2.1 and will be removed in 2.3. Use Range instead.', E_USER_DEPRECATED);
-
- parent::__construct($options);
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDefaultOption()
- {
- return 'limit';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getRequiredOptions()
- {
- return array('limit');
- }
-}
@@ -1,51 +0,0 @@
-<?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;
-
-/**
- * @Annotation
- *
- * @api
- *
- * @deprecated Deprecated since version 2.1, to be removed in 2.3.
- */
-class MaxLength extends Constraint
-{
- public $message = '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 $limit;
- public $charset = 'UTF-8';
-
- public function __construct($options = null)
- {
- trigger_error('MaxLength is deprecated since version 2.1 and will be removed in 2.3. Use Length instead.', E_USER_DEPRECATED);
-
- parent::__construct($options);
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDefaultOption()
- {
- return 'limit';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getRequiredOptions()
- {
- return array('limit');
- }
-}
@@ -1,62 +0,0 @@
-<?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\ConstraintValidator;
-use Symfony\Component\Validator\Exception\UnexpectedTypeException;
-
-/**
- * @author Bernhard Schussek <bschussek@gmail.com>
- *
- * @api
- *
- * @deprecated Deprecated since version 2.1, to be removed in 2.3.
- */
-class MaxLengthValidator extends ConstraintValidator
-{
- public function __construct($options = null)
- {
- trigger_error('MaxLengthValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
- }
-
- /**
- * {@inheritDoc}
- */
- public function validate($value, Constraint $constraint)
- {
- if (null === $value || '' === $value) {
- return;
- }
-
- if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
- throw new UnexpectedTypeException($value, 'string');
- }
-
- $stringValue = (string) $value;
-
- if (function_exists('grapheme_strlen') && 'UTF-8' === $constraint->charset) {
- $length = grapheme_strlen($stringValue);
- } elseif (function_exists('mb_strlen')) {
- $length = mb_strlen($stringValue, $constraint->charset);
- } else {
- $length = strlen($stringValue);
- }
-
- if ($length > $constraint->limit) {
- $this->context->addViolation($constraint->message, array(
- '{{ value }}' => $stringValue,
- '{{ limit }}' => $constraint->limit,
- ), $value, (int) $constraint->limit);
- }
- }
-}
@@ -1,56 +0,0 @@
-<?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\ConstraintValidator;
-
-/**
- * @author Bernhard Schussek <bschussek@gmail.com>
- *
- * @api
- *
- * @deprecated Deprecated since version 2.1, to be removed in 2.3.
- */
-class MaxValidator extends ConstraintValidator
-{
- public function __construct($options = null)
- {
- trigger_error('MaxValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
- }
-
- /**
- * {@inheritDoc}
- */
- public function validate($value, Constraint $constraint)
- {
- if (null === $value || '' === $value) {
- return;
- }
-
- if (!is_numeric($value)) {
- $this->context->addViolation($constraint->invalidMessage, array(
- '{{ value }}' => $value,
- '{{ limit }}' => $constraint->limit,
- ));
-
- return;
- }
-
- if ($value > $constraint->limit) {
- $this->context->addViolation($constraint->message, array(
- '{{ value }}' => $value,
- '{{ limit }}' => $constraint->limit,
- ));
- }
- }
-}
@@ -1,51 +0,0 @@
-<?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;
-
-/**
- * @Annotation
- *
- * @api
- *
- * @deprecated Deprecated since version 2.1, to be removed in 2.3.
- */
-class Min extends Constraint
-{
- public $message = 'This value should be {{ limit }} or more.';
- public $invalidMessage = 'This value should be a valid number.';
- public $limit;
-
- public function __construct($options = null)
- {
- trigger_error('Min is deprecated since version 2.1 and will be removed in 2.3. Use Range instead.', E_USER_DEPRECATED);
-
- parent::__construct($options);
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDefaultOption()
- {
- return 'limit';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getRequiredOptions()
- {
- return array('limit');
- }
-}
@@ -1,51 +0,0 @@
-<?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;
-
-/**
- * @Annotation
- *
- * @api
- *
- * @deprecated Deprecated since version 2.1, to be removed in 2.3.
- */
-class MinLength extends Constraint
-{
- public $message = '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 $limit;
- public $charset = 'UTF-8';
-
- public function __construct($options = null)
- {
- trigger_error('MinLength is deprecated since version 2.1 and will be removed in 2.3. Use Length instead.', E_USER_DEPRECATED);
-
- parent::__construct($options);
- }
-
- /**
- * {@inheritDoc}
- */
- public function getDefaultOption()
- {
- return 'limit';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getRequiredOptions()
- {
- return array('limit');
- }
-}
@@ -1,62 +0,0 @@
-<?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\ConstraintValidator;
-use Symfony\Component\Validator\Exception\UnexpectedTypeException;
-
-/**
- * @author Bernhard Schussek <bschussek@gmail.com>
- *
- * @api
- *
- * @deprecated Deprecated since version 2.1, to be removed in 2.3.
- */
-class MinLengthValidator extends ConstraintValidator
-{
- public function __construct($options = null)
- {
- trigger_error('MinLengthValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
- }
-
- /**
- * {@inheritDoc}
- */
- public function validate($value, Constraint $constraint)
- {
- if (null === $value || '' === $value) {
- return;
- }
-
- if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
- throw new UnexpectedTypeException($value, 'string');
- }
-
- $stringValue = (string) $value;
-
- if (function_exists('grapheme_strlen') && 'UTF-8' === $constraint->charset) {
- $length = grapheme_strlen($stringValue);
- } elseif (function_exists('mb_strlen')) {
- $length = mb_strlen($stringValue, $constraint->charset);
- } else {
- $length = strlen($stringValue);
- }
-
- if ($length < $constraint->limit) {
- $this->context->addViolation($constraint->message, array(
- '{{ value }}' => $stringValue,
- '{{ limit }}' => $constraint->limit,
- ), $value, (int) $constraint->limit);
- }
- }
-}
Oops, something went wrong.

0 comments on commit 65e3b16

Please sign in to comment.