fwbrasil / activate

Abandoned: Pluggable persistence in Scala
GNU Lesser General Public License v2.1
299 stars 46 forks source link

Spray JSON Support : createEntityFromJson with missing fields #169

Open alexd6631 opened 9 years ago

alexd6631 commented 9 years ago

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.