-
Notifications
You must be signed in to change notification settings - Fork 17
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
Idea: Validation via decorators #20
Comments
Hey Michael We have branch "version-1.2.7" it was intended to upgrade some dependencies but in this release we can add your functionality so You can branch off from this branch. I think that it would be good to use ConversionListener to extend types and fields with decorators (or maybe you want to add comments), please look at spring-rest2ts-swagger module where ConversionListeners are used to add comments to TS code based on swagger annotations. Such approach gives us possibility to use this new functionality with all models converters. It should be placed in a separate module. In general You are welcome and if You have any question You can write to me directly on linkedin or skype([email protected]) kind regards |
Michael please keep in mind that interfaces exists only in the compile time so I checked TS documentation
As You see You can't even add decorators to interfaces this is the reason why library which You mention requires classes. kind regards |
Thx for the quick reply. 👍 So a good first step for me would be to create a ConversionListener that can add the validation rules as comments. The developer can then use that info for manually adding the validation rules to his forms. Later on, maybe we can revisit the optiob to output TS classes instead of interfaces in order to add validation as functional decorators. The benefit would be that forms could easily validate the object being edited without any manually created validation rules on the front end side. I am on vacation the next 2 weeks, but when I get back I will look into adding validation rules as comments - and in a new separate module. |
ok, sounds good, have a nice holidays :) |
Hi Michael |
I have been looking at your solution and find it quite interesting. One thing we would like to have in our types is however details about validation.
In our backend entities we have validation based on hibernate validation annotations. Projects exists to have something similar in typescript fx https://github.com/typestack/class-validator. But it requires output to be typescript classes instead of interfaces.
Is there any interest in having such an option in this project? If so, I could probably add a new module for it as a PR.
The text was updated successfully, but these errors were encountered: