someName
someName

Reputation: 1273

Validation framework in C#?

In the java world there is the bean validation framework JSR-303 which is a nicely well thought out strategy for performing data validation in both the presentation and persistence layers of an application. It covers a lot of things, including validation of whole graph models, validation domain grouping, i18n, etc.

I have failed to find any data model validation frameworks in C#. Are there anything similar to JSR-303 in C#?

Upvotes: 6

Views: 2307

Answers (4)

Joel Coehoorn
Joel Coehoorn

Reputation: 416131

On the front end:

The web side (asp.net) has Validation controls for web forms, and Validation Helpers for MVC. Both of these are smart enough to know how to render validation logic to the client page (for faster failure responses and reduced server load) and duplicate the necessary logic server-side (since you can't trust the client).

The Windows side has Error Providers for winforms. I'm not sure about WPF/Silverlight, or if there's anything for Console apps.

The result is that things are a little fragmented, but not so bad that you can't quickly find what you need. The idea is find the approach that's best for each platform, rather than shoehorning different platforms to the same set of principles.

On the back end, you can use the Enterprise Validation Application Block.

Upvotes: 2

Christian Horsdal
Christian Horsdal

Reputation: 4932

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

Upvotes: 0

ADIMO
ADIMO

Reputation: 1117

You can try fluent validation:

http://fluentvalidation.codeplex.com/

Upvotes: 3

StingyJack
StingyJack

Reputation: 19479

There is the Enterprise Library Validation block. http://msdn.microsoft.com/en-us/library/ff648831.aspx

It may not do some of the specific items you are asking about (i18n) out of the box, but it fits the bill for many other use cases.

Also, is free to use and has source code available.

Upvotes: 2

Related Questions