effect resolver #12121
Unanswered
titouancreach
asked this question in
Q&A
effect resolver
#12121
Replies: 2 comments
-
I think the handleSubmit should receive both the original and decoded data for SSR use cases. Imagine this form data gets sent to the server where it must also validate the data. It would need the original values so you can decode using the same schema on the client and server. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello 👋
With @effect/schema, we have the ability to define a Schema that encode/decode to another type.
See this example:
This is represented as
Schema<A, I>
where A is{ readonly createdAt: Date }
and I is{ readonly createdAt: string }
.Currently the
effect-ts
resolver cannot exploit its full potential, because the same type A is used everywhere, example:So I've looked at the source and we have a notion of
TTransformedValue
. It's not very documented but it looks that this is the type after they are transformed by the validator.So in this example, TFieldValues would be
{ createdAt: string }
and the TTransformedValue would be{ createdAt: Date }
.Si I tweaked the effect resolver a little bit, and at the end I got the correct type (and correct runtime as well), but from the user side, it's far from perfect :
It's far from perfect because:
Schema<A, I>
(ie:Schema<TTransformedValues, TFieldValues>
So before submitting a pull request, we want to know if:
I think this would be benefit, not only for the effect resolver, but for all the resolver that are able to transform types.
Thanks very much for reading this
Beta Was this translation helpful? Give feedback.
All reactions