views:

124

answers:

4

I'm building an .NET library and was wondering if there's any validation framework for that. My intention is just validate data-fields, you know, something like ASP.NET MVC validation attributes. There is any?

Post-comments edit:

Actually I am not using any framework like WPF or MVC. Just "plain object" library for data handling. I need to check, for instance, if some object was properly "filled" (mandatory fields, dates and etc).

+5  A: 

Enterprise Library - Sorry, added better link.

Martin
+1 That's what I was going to post as well.
Walter
This is a valid answer, but I'm not sure I'd recommend this library, in general.
Steven Sudit
+4  A: 

The validation attributes that MVC uses are part of System.ComponentModel.DataAnnotations, and can be used in ASP.NET MVC, Silverlight, and WPF. With fairly minimal work, they can be incorporated into data models for at least some ORMs, assuming that the data model is not replaced when updated. (or, with some additional pain, metadata classes can be attached to data models, but as separate partial classes for the data model).

ASP.NET web forms has its own set of validation controls. They run both client and server side, as part of the UI, but don't extend to data model validation.

WinForms has some interesting error indicators that can be use programmatically to manage error detection and require validation, but the validation itself is basically up to the developer.

FWIW, I strongly support the data annotations framework, and wish it could be available retroactively to other .NET environments. (Currently stuck in web forms, and missing those annotations.)

Cylon Cat
+1  A: 

Entity Framework 4 and CSLA have validation solutions built in, if you use either of them.

Guy Starbuck
+2  A: 

I like to use nvalid

This is a fluent validation framework, works very well, you can create custom rules, custom error messages. Multiple context support.

http://nvalid.net/

couellet