Skip to content

Commit 73312ab

Browse files
author
Hugo Hamon
committed
[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: -
1 parent d407be0 commit 73312ab

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Symfony/Component/Validator/Constraints/TypeValidator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public function isValid($value, Constraint $constraint)
3535
return true;
3636
}
3737

38-
$type = $constraint->type == 'boolean' ? 'bool' : $constraint->type;
38+
$type = strtolower($constraint->type);
39+
$type = $type == 'boolean' ? 'bool' : $constraint->type;
3940
$function = 'is_'.$type;
4041

4142
if (function_exists($function) && call_user_func($function, $value)) {

tests/Symfony/Tests/Component/Validator/Constraints/AssertTypeValidatorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public function getValidValues()
6262
$file = $this->createFile();
6363

6464
return array(
65+
array(true, 'Boolean'),
66+
array(false, 'Boolean'),
6567
array(true, 'boolean'),
6668
array(false, 'boolean'),
6769
array(true, 'bool'),

0 commit comments

Comments
 (0)