Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Validator] added improve support for collection validation#9988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
mrcmorales wants to merge3 commits intosymfony:masterfrommrcmorales:ticket_9888
Closed
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
[Validator] Fixed phpcs issues
  • Loading branch information
@mmoreram
mmoreram committedJan 9, 2014
commit5fff51ad83930642a1a789a087566973a9a138cd
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,6 @@ abstract class AbstractComposite extends Constraint
*/
public $constraints = array();


/**
* {@inheritDoc}
*/
Expand DownExpand Up@@ -95,7 +94,6 @@ public function __construct($options = null)
}
}


/**
* Adds the given group if this constraint is in the Default group
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

missing.

*
Expand All@@ -114,7 +112,6 @@ public function addImplicitGroupName($group)
}
}


/**
* {@inheritDoc}
*/
Expand All@@ -123,7 +120,6 @@ public function getDefaultOption()
return 'constraints';
}


/**
* {@inheritDoc}
*/
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,6 @@ abstract class AbstractCompositeValidator extends ConstraintValidator
*/
abstract public function doValidate($value, Constraint $constraint);


/**
* {@inheritDoc}
*/
Expand Down
2 changes: 0 additions & 2 deletionssrc/Symfony/Component/Validator/Constraints/All.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,6 @@

namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Constraints\Each;

/**
* @Annotation
*
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,9 +11,6 @@

namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\EachValidator;

/**
* @author Bernhard Schussek <bschussek@gmail.com>
*
Expand Down
4 changes: 1 addition & 3 deletionssrc/Symfony/Component/Validator/Constraints/Each.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,6 @@

namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Constraints\AbstractComposite;

/**
* @Annotation
*
Expand All@@ -24,4 +22,4 @@
*/
class Each extends AbstractComposite
{
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,8 +12,6 @@
namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Constraints\AbstractCompositeValidator;

/**
* @author Marc Morera Merino <hyuhu@mmoreram.com>
Expand Down
4 changes: 0 additions & 4 deletionssrc/Symfony/Component/Validator/Constraints/None.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,10 +11,6 @@

namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Constraints\AbstractComposite;
use Symfony\Component\Validator\Exception\MissingOptionsException;


/**
* @Annotation
*
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,10 +12,6 @@
namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Constraints\AbstractCompositeValidator;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;


/**
* @author Marc Morera Merino <hyuhu@mmoreram.com>
Expand DownExpand Up@@ -48,7 +44,7 @@ public function doValidate($value, Constraint $constraint)
*/
$this->context->clearViolations();

if ($constraintsSuccess > 0){
if ($constraintsSuccess > 0){
$this->context->addViolation($constraint->violationMessage);
}
}
Expand Down
4 changes: 1 addition & 3 deletionssrc/Symfony/Component/Validator/Constraints/Some.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,10 +11,8 @@

namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Constraints\AbstractComposite;
use Symfony\Component\Validator\Exception\MissingOptionsException;


/**
* @Annotation
*
Expand DownExpand Up@@ -79,7 +77,7 @@ public function __construct($options = null)
throw new MissingOptionsException(sprintf('"min" or "max" and "exactly" must not be given at the same time: %s', __CLASS__), array('min', 'max', 'exactly'));
}

if (!isset($this->min) && !isset($this->exactly)){
if (!isset($this->min) && !isset($this->exactly)){
$this->min = 1;
}

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,10 +12,6 @@
namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Constraints\AbstractCompositeValidator;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;


/**
* @author Marc Morera Merino <hyuhu@mmoreram.com>
Expand DownExpand Up@@ -48,7 +44,7 @@ public function doValidate($value, Constraint $constraint)
*/
$this->context->clearViolations();

if (isset($constraint->exactly) && $constraintsSuccess != $constraint->exactly){
if (isset($constraint->exactly) && $constraintsSuccess != $constraint->exactly){

$this->context->addViolation($constraint->exactlyMessage, array(
'{{ limit }}' => $constraint->exactly,
Expand All@@ -57,15 +53,15 @@ public function doValidate($value, Constraint $constraint)
return;
}

if (isset($constraint->min) && $constraintsSuccess < $constraint->min){
if (isset($constraint->min) && $constraintsSuccess < $constraint->min){
$this->context->addViolation($constraint->minMessage, array(
'{{ limit }}' => $constraint->min,
));

return;
}

if (isset($constraint->max) && $constraintsSuccess > $constraint->max){
if (isset($constraint->max) && $constraintsSuccess > $constraint->max){
$this->context->addViolation($constraint->maxMessage, array(
'{{ limit }}' => $constraint->max,
), null, true);
Expand Down
1 change: 0 additions & 1 deletionsrc/Symfony/Component/Validator/Constraints/Unique.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@

namespace Symfony\Component\Validator\Constraints;


use Symfony\Component\Validator\Constraint;

/**
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,6 @@
namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\AbstractCompositeValidator;

/**
* @author Marc Morera Merino <hyuhu@mmoreram.com>
Expand All@@ -28,7 +27,7 @@ class UniqueValidator extends AbstractCompositeValidator
*/
public function doValidate($value, Constraint $constraint)
{
if ($this->findRepeated($value)){
if ($this->findRepeated($value)){

$this->context->addViolation($constraint->uniqueMessage, $params=array());
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,6 @@ class AbstractCompositeTest extends \PHPUnit_Framework_TestCase
*/
private $simpleConstraint;


/**
* Setup method
*/
Expand All@@ -43,7 +42,6 @@ public function setUp()
->getMock();
}


/**
* Collection groups: none
* Constraint groups: none
Expand DownExpand Up@@ -73,7 +71,6 @@ public function testEmptyGroups()
));
}


/**
* Collection groups: [Default, Group1]
* Constraint groups: none
Expand DownExpand Up@@ -111,7 +108,6 @@ public function testCollectionGroups()
));
}


/**
* Collection groups: none
* Constraint groups: [Default, Group1]
Expand DownExpand Up@@ -158,7 +154,6 @@ public function testConstraintsGroups()
));
}


/**
* Collection groups: none
* Constraint groups: [Default, Group1]
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@

use Symfony\Component\Validator\ExecutionContext;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\None;
use Symfony\Component\Validator\Constraints\NoneValidator;
use Symfony\Component\Validator\Tests\Fixtures\FakeMetadataFactory;
Expand DownExpand Up@@ -190,8 +189,6 @@ public function testNotSuccessValidate($array)
);
}



/**
* Adds validateValue assertions
*/
Expand DownExpand Up@@ -265,7 +262,6 @@ public function testFunctionalNotSuccessExactly()
$this->assertCount(1, $visitor->getViolations());
}


/**
* Data provider
*/
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@

use Symfony\Component\Validator\ExecutionContext;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Some;
use Symfony\Component\Validator\Constraints\SomeValidator;
use Symfony\Component\Validator\Tests\Fixtures\FakeMetadataFactory;
Expand DownExpand Up@@ -665,7 +664,6 @@ protected function setValidateValueAssertions($array, $constraint1, $constraint2
}
}


/**
* Data provider
*/
Expand All@@ -676,4 +674,4 @@ public function getValidArguments()
array(new \ArrayObject(array(5, 6, 7))),
);
}
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,6 @@
namespace Symfony\Component\Validator\Tests\Constraints;

use Symfony\Component\Validator\Constraints\Unique;
use Symfony\Component\Validator\Constraints\Valid;

/**
* @author Marc Morera Merino <hyuhu@mmoreram.com>
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,8 +12,6 @@
namespace Symfony\Component\Validator\Tests\Constraints;

use Symfony\Component\Validator\ExecutionContext;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Unique;
use Symfony\Component\Validator\Constraints\UniqueValidator;
use Symfony\Component\Validator\Tests\Fixtures\FakeMetadataFactory;
Expand DownExpand Up@@ -156,4 +154,4 @@ public function testFunctionalNotSuccessExactly()
$visitor->validate(new EntityCollection(), 'Default', '');
$this->assertCount(1, $visitor->getViolations());
}
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,4 +28,4 @@ class EntityCollection
*
*/
protected $collectionNotUnique = array(1,2,3,1,2);
}
}

[8]ページ先頭

©2009-2025 Movatter.jp