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
For example, Validator[MyType].validate(request) returns a list of failures when validate_at_construction is set to false. I would like similar behavior for type mappers.
One workaround I can think of is to avoid type mapping and instead just use the Validator instance, then perform unsafe operations (NonEmptyString.unsafeFrom), assuming the data has already been validated based on the appropriate rules.
Thank you,
Chad Daksha
The text was updated successfully, but these errors were encountered:
Hi @chaddaksha , this is a valid issue, though introducing TypeMappers that can collect errors lead to a fairly large change in ScalaPB that is unlikely to be introduced due to complexity added versus user demand. (I am open to be convinced otherwise if we see demand for this showing up in the future)
For the time being, we can consider something along the lines of your suggestion: maybe you can find a way to generate the case classes twice, one with a permissive structure (String), and one with the refined structures, do validation on the permissive type and unsafe conversion to the second.
Hi,
I'm trying to automatically map protobuf types to refined types. Is it possible to do so in a safe way that would allow for easy error handling (i.e., as opposed to throwing)?
For example,
Validator[MyType].validate(request)
returns a list of failures whenvalidate_at_construction
is set tofalse
. I would like similar behavior for type mappers.One workaround I can think of is to avoid type mapping and instead just use the
Validator
instance, then perform unsafe operations (NonEmptyString.unsafeFrom
), assuming the data has already been validated based on the appropriate rules.Thank you,
Chad Daksha
The text was updated successfully, but these errors were encountered: