[Validator] The Type constraint now accepts the "Boolean" type instead of "boolean".

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
This commit is contained in:
Hugo Hamon 2011-10-11 12:27:45 +02:00
parent d407be068d
commit 73312ab5e9
2 changed files with 4 additions and 1 deletions

View File

@ -35,7 +35,8 @@ class TypeValidator extends ConstraintValidator
return true;
}
$type = $constraint->type == 'boolean' ? 'bool' : $constraint->type;
$type = strtolower($constraint->type);
$type = $type == 'boolean' ? 'bool' : $constraint->type;
$function = 'is_'.$type;
if (function_exists($function) && call_user_func($function, $value)) {

View File

@ -62,6 +62,8 @@ class TypeValidatorTest extends \PHPUnit_Framework_TestCase
$file = $this->createFile();
return array(
array(true, 'Boolean'),
array(false, 'Boolean'),
array(true, 'boolean'),
array(false, 'boolean'),
array(true, 'bool'),