-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SUGGESTION: guidance for write-side validation of constraints #966
Comments
This one may be tough. The first thing that came to mind was changing the This would be a breaking change, and we'd probably want to offer an |
Hi @caoilte, in the current stateit'd be possible to write something like :
which would let you derive a validator for any generated type.
I think I'd welcome this change. @daddykotex or @lewisjkl, any of you want to tackle this ? Or someone on your team, @kubukoz ? |
I'm happy to take a look at this. A few clarification questions:
|
probs just newtypes.
instead of, but the current constructor would be rebranded as |
@lewisjkl are you still looking at this? |
Awesome, yeah I totally dropped the ball on this. Appreciate you taking it on. |
@Baccata are we looking to introduce a SmartNewType or modify the existing Newtype class and change all existing calls to apply to unsafe (will be a lot of generated code changes ) |
I'm thinking we shouldn't make such a change required for users updating to 0.18. Can we have a deprecation cycle?
@yisraelU sorry but this doesn't answer your question 😅 |
@kubukoz I have done some work in it , but waiting on some guidance |
I don't have bandwidth to offer guidance on this, besides maybe looking at previous art: https://github.com/monix/newtypes/blob/main/core/shared/src/main/scala/monix/newtypes/NewValidated.scala |
@denisrosca is looking into this. We identified a couple axes of the problem:
and for now we'll tackle just the most obvious case, "wrapped" (default) newtypes with constraint traits applied directly. It appears that user-defined refinements do not need any work to be done, because their construction is by design constrained by what the user does in their refinement provider. |
disclaimer: We're only using smithy4s as an IDL for events so this description is written from that point of view and may need translation in your head to make sense from a more service oriented perspective.
It would be really nice if there was an on rails way to check that smithy case classes have been constructed such that they pass all the constraints defined on the corresponding IDL. I only just realised it wasn't happening when our smithy defined events started failing validation on rehydration. My team will probably solve the problem by writing scalacheck tests that do a round trip on all our event structures (ie check that they can be turned into JSON and back again without erroring). It would be nice if there was an idiomatic way to check at runtime rather than relying on test exhaustivity but perhaps it isn't practical. Nevertheless @kubukoz suggested raising this issue as a placeholder to discuss.
The text was updated successfully, but these errors were encountered: