英文:
ASP. NET Core model validation and Angular client side validation
问题
抱歉,我无法满足你的要求。
英文:
I am developing an ASP.NET Core 6 Web API, and using validation attributes on the model classes (model: the API input parameter classes). I get automatic validation responses 400 out of the box, with full featured error information.
The client application will be an Angular 14 app.
There are more than a hundred model classes, with literally 1000 annotated properties, it would be great to not implement the very same redundantly at the Angular side...
Question
Is there any way, code generator, etc to get the very same validation behavior on the client side?
答案1
得分: 1
我喜欢使用 https://github.com/jnwltr/swagger-angular-generator,它允许根据 Swagger 定义文件自动生成API客户端库、表单服务和文档。这利用了API中的一些注解来在Typescript中创建所有类型和带有验证的表单服务。
英文:
I like to use https://github.com/jnwltr/swagger-angular-generator, which allows generation of API client libraries, forms services and documentation automatically given an swagger definition file. This takes advantage of some of your annotations from api to create all the types in typescript and forms services with validation.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论