Business Validations

Business Validations

Old forum URL: forums.lhotka.net/forums/t/11354.aspx


tanny posted on Friday, May 11, 2012

All,

I'm newbie to CSLA and I'm trying to implement validations in my application (Business layer -> CSLA). I have requirement where in batch application we would check the data in DB against some business conditions and perform appropriate business logic accordingly. Later when these data entities are viewed from the screen, the same appropriate validation message needs to be displayed in the screen as well.

I'm just in initial approach phase, where I'm thinking if its required to store the appropriate validation message against that data entity or use the Business validation rules in CSLA for the same.

If in CSLA, can someone please share me some samples on business validation rules?

Thanks!

Regards,

Tanny

JonnyBee replied on Friday, May 11, 2012

Hi,

CSLA does NOT support the idea of storing broken rules in the database and restoring them as part of the fetch operation later.

BusinessRules is a lot more than just validation and broken rules so you should run all your Business Rules when you fetching the Editable object.
You _could_ save broken rules to a database and just load as an information string property on a readonly object but it would not be recommended by me.

You should be aware that Broke Rules can be

For samples look at the UsingCsla4-02-Objects ebook available for purchase at http://store.lhotka.net and the samples download projects

\Samples\Net\cs\RuleTutorial
\Samples\Net\cs\BusinessRuleDemo
\Samples\Net\cs\ProjectTracker

So my recommendation is:

1. If batch processing is time / performance critical - do the checks in the database if possible. That will always give the best performance.

2. Create/Add Business rules to CSLA entities to run when you load objects for edit. 

Copyright (c) Marimer LLC