Pierre Greborio.NET

Talking about .NET world

Attribute-based data validation

Attributes gives a great power for some kind of control over entities, operations and attributes in OOP. NewTelligence posted an interesting library that uses, in a clever manner, custom attributes to validate the data of business objects.

Though it is complete for most of scenarios, I think it lacks on other. Validation rules aren't "absolute" defined. They can depends from two factors: current user and context. For example, you could have a field (or property) that is mandatory if the user is a manager whereas optional for an employee. Or, you could have a property that is mandatory for a customer but it isn't for a prospect. Then, it should be nice to add also the concept of role and context, more or less as ASP.NET does.

Anyway, that is a very good starting point for building a complete and efficient data validation system.

Comments

No Comments