Reputation: 5640
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).
Upvotes: 2
Views: 849
Reputation: 6508
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.
Upvotes: 2
Reputation: 21873
Entity Framework 4 and CSLA have validation solutions built in, if you use either of them.
Upvotes: 1
Reputation: 7201
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.)
Upvotes: 4