php - Symfony validation wrong type invalid value
one text
I have an entity with the following property and Type validation but i always get a wrong type error validation.wrong_type
, when i debug it says invalid value it seems that the Space isnt denormalized maybe?
/**
* @var Space|null
* @Assert\Valid(groups={"Default"})
* @Assert\Type(Space::class, message=Message::VALIDATION_MESSAGE_WRONG_TYPE, groups={"Default"})
*/
public $space;
This is what my Space entity looks like:
final class Space
{
/**
* @var float|null
* @Assert\NotBlank(message=Message::VALIDATION_MESSAGE_NOT_BLANK, groups={"Default","Partial"})
* @Assert\Type(type="float", message=Message::VALIDATION_MESSAGE_WRONG_TYPE, groups={"Default","Partial"})
*/
public $value;
/**
* @var string|null
* @Assert\NotBlank(message=Message::VALIDATION_MESSAGE_NOT_BLANK, groups={"Default","Partial"})
* @Assert\Type(type="string", message=Message::VALIDATION_MESSAGE_WRONG_TYPE, groups={"Default","Partial"})
*/
public $unit;
}
This is how I pass it in my request:
"space": {
"value": 54.47,
"unit": "m??"
},
What am I doing wrong here
Source