[Form] Fixed: IntegerToLocalizedStringTransformer does not accept "NaN" as valid number anymore
This commit is contained in:
parent
8c63d6d1e5
commit
0533c1b40f
@ -35,6 +35,10 @@ class IntegerToLocalizedStringTransformer extends NumberToLocalizedStringTransfo
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('NaN' === $value) {
|
||||||
|
throw new TransformationFailedException('"NaN" is not a valid integer');
|
||||||
|
}
|
||||||
|
|
||||||
$formatter = $this->getNumberFormatter();
|
$formatter = $this->getNumberFormatter();
|
||||||
$value = $formatter->parse(
|
$value = $formatter->parse(
|
||||||
$value,
|
$value,
|
||||||
|
@ -70,4 +70,24 @@ class IntegerToLocalizedStringTransformerTest extends LocalizedTestCase
|
|||||||
|
|
||||||
$transformer->reverseTransform('foo');
|
$transformer->reverseTransform('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
|
||||||
|
*/
|
||||||
|
public function testReverseTransformDisallowsNaN()
|
||||||
|
{
|
||||||
|
$transformer = new IntegerToLocalizedStringTransformer();
|
||||||
|
|
||||||
|
$transformer->reverseTransform('NaN');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
|
||||||
|
*/
|
||||||
|
public function testReverseTransformDisallowsNaN2()
|
||||||
|
{
|
||||||
|
$transformer = new IntegerToLocalizedStringTransformer();
|
||||||
|
|
||||||
|
$transformer->reverseTransform('nan');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user