symfony/symfony — Issue #3513: [Validation] Type contraint doesn't work with integers
Author: clemherreman
Created: 2012-03-06 11:46:54+00:00
State: open

Hello,
If you put a validation integer type contraint on a field, a violation is always triggered after the form submission, as what comes from the form is always a string.

## Example

```php
isValid()`, this assertion is never validated, as it calls `is_int("2")`, which returns `false`, instead of an expected `true`.

I think this is kind of broken, as anyone would expect this to be validated.

## Workaround

Casting the new value in the `$serialNumber` setter. But to do so, I need to check that the new value is an integer, making the `@Assert\Type` useless.

Thank you.