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
My team would like to start making use of additional JSON properties to document extra validation.
The idea is that producers can use these to document validation they support, but consumers can also define them in addition to what the producer schema has. Eventually, we see this as a way to introduce data contracts.
For example:
Min/Max size strings
Regex for strings
Min/Max length of collections
Confluent recently introduced a set of features in this space, but these are alongside the schemas not within, and we aren't using the Confluent platform in any case.
Adding the props is relatively easy, as we can use this method for properties OF a record:
The problem comes when we try to parse these props when decoding.
Originally i thought we could use codec: Codec[B] and generate a new codec by calling imapError and return a Left(AvroError) if something failed validation. But imapError hides the writer schema.
Ultimately i think the only way of doing what I want is to use this deprecated method:
My team would like to start making use of additional JSON properties to document extra validation.
The idea is that producers can use these to document validation they support, but consumers can also define them in addition to what the producer schema has. Eventually, we see this as a way to introduce data contracts.
For example:
Confluent recently introduced a set of features in this space, but these are alongside the schemas not within, and we aren't using the Confluent platform in any case.
Adding the props is relatively easy, as we can use this method for properties OF a record:
And the below allows us to define props for each of the field IN a record:
Passing in props to the field builder results in a Schema like this:
The problem comes when we try to parse these props when decoding.
Originally i thought we could use
codec: Codec[B]
and generate a new codec by callingimapError
and return aLeft(AvroError)
if something failed validation. ButimapError
hides the writer schema.Ultimately i think the only way of doing what I want is to use this deprecated method:
I can see a similar issue was raised here: #504 which they resolved by adding something to the library.
Do you have any suggestions if there's something else I can true, or perhaps this is something of a feature request?
The text was updated successfully, but these errors were encountered: