0

I'm using JMSSerializerBundle for deserializer a json on an API, so I wanna check if the values are correct so I'm using Symfony annotation validation, but when on integer value the json have a string value JMSSerializerBundle put how default value at 0.

Is any way to return a error about this field or another integer fields when is not an integer.

Exemple:

{
"id":1, //integer
"name":"sad", //string
"simulation_id":"blablaba" //integer
}
JMSSerializerBundle Deserialize to

{
"id":1,
"name":"sad",
"simulation_id":0
}

I would like have a error like

{

    "property_path": "simulationId",
    "message": "The value 'sad' is not a valid."
}
fredpalas
  • 66
  • 7

1 Answers1

0

I found the answer on this post:

How to make JMS Serializer throw an exception on deserializing JSON instead of coercing types?

Community
  • 1
  • 1
fredpalas
  • 66
  • 7