activate icon indicating copy to clipboard operation
activate copied to clipboard

Spray JSON Support : createEntityFromJson with missing fields

Open alexd6631 opened this issue 10 years ago • 0 comments

createEntityFromJson allows you construct entity with missing "required" fields in the JSON

For instance given the following model :

class Person(var firstName: String,
              var lastName: String,
              var age: Int) extends Entity

it is possible to create an entity with the json data :

{ "firstName": "alex", "lastName" : "test"}

However, the entity will be in a very inconsistent state. A more appropriate behaviour would be to reproduce the logic in EntityMap.createEntityUsingConstructor, ie preventing creation of entity if no matching constructor is found.

alexd6631 avatar Feb 18 '15 20:02 alexd6631