ASP.NET Core模型验证和Angular客户端验证

huangapple go评论64阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年2月16日 13:12:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75468086.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定