You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's currently a weird dichotomy with ModelSchema being a "serialization descriptor" for objects and PropSchema being one for all other types of values. There's object() which converts ModelSchema -> PropSchema, and the logic which would be in ModelSchema.serializer is instead the separate function "serialize".
This would be a breaking change, but as I've already got one in after the TypeScript conversion I'm considering making this change too.
Basically it would change ModelSchema to implements PropSchema, deserialize would just create a new Context and then delegate to the passed "PropSchema". object() and createSimple/ModelSchema would be unified and contain the logic previously part of serialize and deserialize.
@NaridaL sounds good in the abstract, but I haven't been using or working on this package for a couple of years :) Would you mind giving a quick example of what the breaking would look like from consumer perspective?
Also this unification would enable thing like deserialize(list(A), [...stuff...]) or deserialize(reference(User, findUserById), {...some serialize representation of id...})
i.e. it'll enable re-use of already-declared logic even where you have contents of just the property with you, instead of a class that houses the property.
This re-use is incredibly useful when declaring custom serializers that want to invoke serialization/deserialization on a sub-part of the data.
There's currently a weird dichotomy with ModelSchema being a "serialization descriptor" for objects and PropSchema being one for all other types of values. There's
object()
which converts ModelSchema -> PropSchema, and the logic which would be in ModelSchema.serializer is instead the separate function "serialize".This would be a breaking change, but as I've already got one in after the TypeScript conversion I'm considering making this change too.
Basically it would change ModelSchema to
implements PropSchema
, deserialize would just create a new Context and then delegate to the passed "PropSchema". object() and createSimple/ModelSchema would be unified and contain the logic previously part of serialize and deserialize.Any thoughts? @mweststrate @alexggordon @pyrogenic
The text was updated successfully, but these errors were encountered: