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
This issue is split out from #182, but the problem is the same. For schema.AllOff, if one or more of the members implement as a FieldSerialzier, it should be called in a sensible manner.
Let's discuss a littlebit what the most common use-case for schema.AllOf is before we jump to a soultion. In my mind, the most obvious use-case for AllOf is to validate both a common and a variable set of fields, e.g. something like this:
where commonSchema defines a set of common fields that apply to all items, while schemaA and schemaB describes e.g. a schema for what's valid when say a field "type" is equal either "A" or "B":
That means, presumably, that for FieldSerializer selection on AllOf to be useful:
We also want nested types like Array, Dict, Object to implement FieldSerializer to call serialization on any sub-field that might implement it while ignoring any fields it doesn't know about.
We want to call all FieldSerializers that are found in schema, passing in the output of the previous FieldSerializer as input to the next.
The text was updated successfully, but these errors were encountered:
PS! It would be the user's responsibility to make sure that fields do not overlap between the different all-off members. E.g. if specifying a &schema.AllOf{&schema.Dict{...}, &schema.Object{...}}, and both the dict and object has members that implements FieldSerializers, it's the user's responsibility to add a KeysValidatorthat prevents the dict entry from serializing fields that should be serilized by the object. The same would of-course already be true for Validation, so it should not be unreasonable to assume and document this behaviour.
This issue is split out from #182, but the problem is the same. For
schema.AllOff
, if one or more of the members implement as aFieldSerialzier
, it should be called in a sensible manner.Let's discuss a littlebit what the most common use-case for
schema.AllOf
is before we jump to a soultion. In my mind, the most obvious use-case for AllOf is to validate both a common and a variable set of fields, e.g. something like this:where
commonSchema
defines a set of common fields that apply to all items, whileschemaA
andschemaB
describes e.g. a schema for what's valid when say a field "type" is equal either "A" or "B":That means, presumably, that for FieldSerializer selection on AllOf to be useful:
The text was updated successfully, but these errors were encountered: