Created
January 2, 2013 18:49
-
-
Save baldurrensch/4436827 to your computer and use it in GitHub Desktop.
How to use the All Validator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\Validator\Constraints\Email; | |
use Symfony\Component\Validator\Constraints\All; | |
// This is reduced to the bare minimum. Missing Namespace and other imports | |
class DemoController extends Controller | |
{ | |
function testAction() | |
{ | |
$testArr = array( | |
'[email protected]', | |
'invalid@gmail' | |
); | |
$emailConstraint = new Email(); | |
$collectionConstraint = new All(array($emailConstraint)); | |
$errorList = $this->get('validator')->validateValue( | |
$testArr, | |
$collectionConstraint | |
); | |
echo "<pre>"; | |
print_r($errorList); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Symfony\Component\Validator\ConstraintViolationList Object | |
( | |
[violations:protected] => Array | |
( | |
[0] => Symfony\Component\Validator\ConstraintViolation Object | |
( | |
[messageTemplate:protected] => This value is not a valid email address. | |
[messageParameters:protected] => Array | |
( | |
[{{ value }}] => invalid@gmail | |
) | |
[messagePluralization:protected] => | |
[root:protected] => | |
[propertyPath:protected] => [1] | |
[invalidValue:protected] => invalid@gmail | |
[code:protected] => | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment