-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
support for class-validator #26
Comments
Can you share a code sample with me so that I can understand your problem even better? |
Thanks for the reply, here's an outline:
Hopefully this is clear enough, thanks. |
Is your problem that the derived type is an interface and Modular Forms throws an error when you pass it as generic or does your problem relate to validating the form inputs? |
The former. I am unable to use your previous guidance of using a type instead of an interface |
Unfortunately, I don't know any solution for this at the moment. To make the form values type-safe even with nested objects and arrays, I use a recursive type and this approach leads to problems when using interfaces. I will ask for advice in the TypeScript Discord. However, it is uncertain if there is a solution for this as described in #2. I will report here as soon as I have an answer. |
I received an answer in the TypeScript Discord and am now checking if the given solution works for Modular Forms. |
I have been busy with other things the last few days. I hope to give you feedback on this over the weekend. |
No rush, thanks man |
Sorry. I haven't gotten around to it yet. I'll get back to you as soon as I find time for it. |
Found a workaround: |
Thanks for the info! Do you have a code example? Do you also work with Yup and need adapters for validation with Modular Forms? |
All solutions I know so far to be able to support interfaces reduce type safety. I have again experimented a bit, but have not come to a satisfactory solution. |
I'm temporarily closing the issue until there are signs that changes to our code can fix the problem. |
I have some external classes define the shape of some forms, as they are classes, inferring the shape of a Zod schema is non-trivial, I have previously used https://github.com/typestack/class-validator for validation, but I have run into the situation outlined in #2 are there any other workarounds that could enable this?
The text was updated successfully, but these errors were encountered: