Web Applications and Field/Entity validation

Posts   
 
    
Jez
User
Posts: 198
Joined: 01-May-2006
# Posted on: 22-Jul-2006 16:51:35   

This is something I've been pondering over recently, and would appreciate any thoughts on the subject.

Currently I develop and maintain a fairly large web based application that uses LLBLGen for the DAL. Recently, I've had to create some smaller applications that reference the same DAL.

However, all my field validation is done through the built in ASP.NET validation controls (RequiredFieldValidator, RegularExpressionValidator etc) and as such I am having to re-implement this functionality in the other applications.

I am considering replacing these validation controls with LLBLGen Validator classes (thereby allowing me to share the validation logic accross the applications) and was wondering whether anyone thinks this is worthwhile. What I need to be able to do is bubble the error messages up to my UI and display them in a control similar to the built in ASP.NET ValidationSummary.

Is there a recommended way to do this? When using the LLBLGenProDataSources with LivePersistence disabled, I assume I could catch any ORMEntityValidatorExceptions inside the PerformWork event, but how would I go about doing this with LivePersistence enabled?

Any thoughts would be welcome and appreciated.

Jez

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 22-Jul-2006 18:48:07   

I would place the validation in both locations. Both the aspx validation controls and the DAL.

Error checking the entity in the DAL prevents middle layer attacks on the database. And when you use the DAL in multiple projects your base error checking is available.

The aspx validation is more for the end user and to validate the data before it reaches the DAL. While this is redundate it gives you multiple layers of error checking. With asp.net input validation is very easy anyway.

Posts: 1263
Joined: 10-Mar-2006
# Posted on: 24-Jul-2006 00:01:12   

I thought the new validation in LLBLGen v2 you could integrate this using IDataErrorInfo or something?

Anyone done this?

Jez
User
Posts: 198
Joined: 01-May-2006
# Posted on: 24-Jul-2006 09:36:49   

As far as I know, IDataErrorInfo is for use with the Windows Forms ErrorProvider control. I could not find any way of using IDataErrorInfo with the ASP.NET ValidationSummary.

There seems to be some good information about using IDataErrorInfo in this post: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=6259