I have an entity and a column with type boolean
/**
* @ORM\Column(type="boolean", nullable=false)
* @Assert\NotBlank()
*/
private $isActive;
When I try to add a string to this column (just to test) I get this error message
The type of the attribute must be bool, string given
So, I add the validation type
* @Assert\Type(
* type="boolean",
* message="The value {{ value }} is not a valid {{ type }}."
* )
but always the message error launched, so, I try the second solution by creating my own Asset validation
if(false === is_bool($user->getIsActive())){
$this->context->buildViolation($constraint->message)->atPath('isActive')->addViolation();
}
but always the code crushed and the message appears.
PS: if I change the column type to string the validation work correctly, but I want to use the bool type with validation, is there any solution?
I fixed this issue by adding this line :
/**
* @ApiResource(
* denormalizationContext={
* "disable_type_enforcement"=true
* }
* )
*/