Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a validation framework for .NET?

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).

like image 280
Eduardo Cobuci Avatar asked Mar 17 '26 00:03

Eduardo Cobuci


2 Answers

Enterprise Library - Sorry, added better link.

like image 54
Martin Avatar answered Mar 18 '26 20:03

Martin


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.)

like image 39
Cylon Cat Avatar answered Mar 18 '26 19:03

Cylon Cat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!