Basic Database Validation

Posts   
 
    
jader201
User
Posts: 33
Joined: 20-Mar-2007
# Posted on: 05-Jul-2007 21:55:09   

I would put this in Feature Requests, but I'm betting this either has already been brought up and explained why it wasn't done, or is being considered for future releases. I did search the boards, but couldn't find anything on my initial searches.

Would it be possible/practical for LLBLGen Pro to include built-in validation support for required fields (not nullable) along with varchar lengths? Or is it already there, and I just don't know how to utilize it?

For example, if I bind an ErrorProvider to a BindingSource bound to an LLBL collection, it would be sweet if the ErrorProvider was populated with any required fields that were missing, or any strings that exceeded the length allowed by the db.

Thanks in advance.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 06-Jul-2007 10:46:18   

This is left for the developer, as some times required fields can be automatically set in the BL away from the UI, so it's a project specific requirement.

Please check the following thread: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=9389

Roman
User
Posts: 23
Joined: 19-May-2006
# Posted on: 07-Mar-2008 20:54:02   

I hate to bring out an old thread, but the links provided don't really address the original question, which I'd like to ask as well. Why is it that NOT NULL fields do not have validation generated that would check for nulls and throw an ORM exception, instead of hitting the DB and failing there? This seems very similar to overflow detection and I haven't seen an adequate explanation for why nulls in required fields are not detected automagically. Sure, I could implement that manually, but why should I have to?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 08-Mar-2008 10:06:49   

Because if you have a default constraint in the DB, you want to have that particular check not to throw an exception. Also, if you use a trigger in the db to fill in data at insert, it's key the check isn't throwing an exception.

That's why the validation has to be done by the developer. If you want to test for mandatory fields on the client, you've to do that yourself.

You can easily write that once, and call that routine from a validator in every entity.

Frans Bouma | Lead developer LLBLGen Pro