Skip to content
Newer
Older
100644 52 lines (44 sloc) 1.39 KB
c56d28d @fabpot renamed Symfony\Components to Symfony\Component
fabpot authored Aug 20, 2010
1 <?php
2
06fcab5 @fabpot [Validation] fixed license
fabpot authored Oct 2, 2010
3 /*
64e1cf2 @blue-eyes normalized license messages in PHP files
blue-eyes authored Jan 15, 2011
4 * This file is part of the Symfony package.
06fcab5 @fabpot [Validation] fixed license
fabpot authored Oct 2, 2010
5 *
fec10a4 @fabpot replaced symfony-project.org by symfony.com
fabpot authored Mar 6, 2011
6 * (c) Fabien Potencier <fabien@symfony.com>
06fcab5 @fabpot [Validation] fixed license
fabpot authored Oct 2, 2010
7 *
64e1cf2 @blue-eyes normalized license messages in PHP files
blue-eyes authored Jan 15, 2011
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
06fcab5 @fabpot [Validation] fixed license
fabpot authored Oct 2, 2010
10 */
11
64e1cf2 @blue-eyes normalized license messages in PHP files
blue-eyes authored Jan 15, 2011
12 namespace Symfony\Component\Validator\Constraints;
13
c56d28d @fabpot renamed Symfony\Components to Symfony\Component
fabpot authored Aug 20, 2010
14 use Symfony\Component\Validator\Constraint;
15 use Symfony\Component\Validator\ConstraintValidator;
16
be4f2a0 @fabpot [Validator] tagged the public @api
fabpot authored Jul 20, 2011
17 /**
529a58d @webmozart [Validator] Removed return value from ConstraintValidatorInterface::i…
webmozart authored Feb 9, 2012
18 * @author Bernhard Schussek <bschussek@gmail.com>
19 *
be4f2a0 @fabpot [Validator] tagged the public @api
fabpot authored Jul 20, 2011
20 * @api
21 */
74e4565 @schmittjoh removed Assert prefix from all constraints, renamed annotation namesp…
schmittjoh authored Mar 26, 2011
22 class TypeValidator extends ConstraintValidator
c56d28d @fabpot renamed Symfony\Components to Symfony\Component
fabpot authored Aug 20, 2010
23 {
be4f2a0 @fabpot [Validator] tagged the public @api
fabpot authored Jul 20, 2011
24 /**
9bde527 @danielholmes [Validator] Added inheritDoc phpdoc for validate methods
danielholmes authored Jul 14, 2012
25 * {@inheritDoc}
be4f2a0 @fabpot [Validator] tagged the public @api
fabpot authored Jul 20, 2011
26 */
734609c @webmozart [Validator] Renamed ConstraintValidatorInterface::isValid() to valida…
webmozart authored Feb 9, 2012
27 public function validate($value, Constraint $constraint)
c56d28d @fabpot renamed Symfony\Components to Symfony\Component
fabpot authored Aug 20, 2010
28 {
3cdba53 @Seldaek CS: Unified strict equality comparisons, put var on the right side
Seldaek authored Dec 21, 2010
29 if (null === $value) {
529a58d @webmozart [Validator] Removed return value from ConstraintValidatorInterface::i…
webmozart authored Feb 9, 2012
30 return;
c56d28d @fabpot renamed Symfony\Components to Symfony\Component
fabpot authored Aug 20, 2010
31 }
32
0d1bbf7 @hhamon [Validator] The Type constraint now accepts the "Boolean" type instea…
hhamon authored Oct 11, 2011
33 $type = strtolower($constraint->type);
34 $type = $type == 'boolean' ? 'bool' : $constraint->type;
88af2a4 @benjamindulau [Validators][Type] Added support for ctype_* functions + tests
benjamindulau authored Nov 1, 2011
35 $isFunction = 'is_'.$type;
36 $ctypeFunction = 'ctype_'.$type;
c56d28d @fabpot renamed Symfony\Components to Symfony\Component
fabpot authored Aug 20, 2010
37
88af2a4 @benjamindulau [Validators][Type] Added support for ctype_* functions + tests
benjamindulau authored Nov 1, 2011
38 if (function_exists($isFunction) && call_user_func($isFunction, $value)) {
529a58d @webmozart [Validator] Removed return value from ConstraintValidatorInterface::i…
webmozart authored Feb 9, 2012
39 return;
0445007 @fabpot updated CHANGELOG for 2.1
fabpot authored Nov 1, 2011
40 } elseif (function_exists($ctypeFunction) && call_user_func($ctypeFunction, $value)) {
529a58d @webmozart [Validator] Removed return value from ConstraintValidatorInterface::i…
webmozart authored Feb 9, 2012
41 return;
0445007 @fabpot updated CHANGELOG for 2.1
fabpot authored Nov 1, 2011
42 } elseif ($value instanceof $constraint->type) {
529a58d @webmozart [Validator] Removed return value from ConstraintValidatorInterface::i…
webmozart authored Feb 9, 2012
43 return;
c56d28d @fabpot renamed Symfony\Components to Symfony\Component
fabpot authored Aug 20, 2010
44 }
45
d7cb249 @webmozart [Validator] Deprecated ConstraintValidator methods setMessage(), getM…
webmozart authored Feb 1, 2012
46 $this->context->addViolation($constraint->message, array(
47 '{{ value }}' => is_object($value) ? get_class($value) : (is_array($value) ? 'Array' : (string) $value),
033c4b1 @fabpot [Validator] removed the convention that error parameters are delimite…
fabpot authored Sep 29, 2010
48 '{{ type }}' => $constraint->type,
c56d28d @fabpot renamed Symfony\Components to Symfony\Component
fabpot authored Aug 20, 2010
49 ));
50 }
2d8d332 @fabpot fixed CS
fabpot authored Jun 8, 2011
51 }
Something went wrong with that request. Please try again.