Validation frame in C #?

In the java world, there is a bean validation system JSR-303 , which is a well-thought-out strategy for validating data at both presentation levels and application persistence. It covers a lot of things, including checking whole graph models, grouping verification domains, i18n, etc.

I was unable to find any framework for validating a data model in C #. Is there something similar to JSR-303 in C #?

+6
source share
4 answers

There is a corporate library health checker. http://msdn.microsoft.com/en-us/library/ff648831.aspx

It may not fulfill some of the specific questions that you ask (i18n) out of the box, but is suitable for a bill for many other use cases.

In addition, you can freely use and have source code.

+2
source
+3
source

At the front end:

On a web page (asp.net) Validation Elements for Web Forms and Validation Helpers for MVC. Both of them are smart enough to know how to visualize the verification logic on the client page (for faster responses about failures and reduce server load) and duplicate the necessary logical server side (since you cannot trust the client).

On the Windows side, there are Error Providers for winforms. I am not sure about WPF / Silverlight, or if something is for console applications.

As a result, things are a bit fragmented, but not so bad that you cannot quickly find what you need. The idea is to find the approach that works best for each platform, rather than teaching different platforms the same principles.

On the back, you can use the app block to test entrepreneurship .

+2
source

There are also data annotations that can help with client and server side validation: http://msdn.microsoft.com/en-us/library/ee256141.aspx

0
source

Source: https://habr.com/ru/post/901665/


All Articles