Validation logic inside entity/validator classes

Posts   
 
    
Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 19-Feb-2007 00:28:08   

Could someone critique the following please?

The LLBLGen Pro v2 documentation states (to paraphrase) that LLBLGen Pro supports storage of validation logic in a separate validator class...

It also says:

In v1.0.2005.1 and earlier, LLBLGen Pro generated for each entity a validator class, called entitynameValidator. This isn't the case anymore. You can still generate validator classes per entity however, you just have to enable the SD.Tasks.Generic.ValidatorClassesGenerator task in the preset of your choice at Tab 3 of the generator configuration dialog.

Is the implication of this simply, that storage of validation logic in a separate validator class is still a valid option, but that one would need to explicitly create this validator class (if one did not choose to generate validator classes per entity)?

i.e. In my situation a significant number of tables are lookups with simple validation rules which could be handled by adding validation logic to the entity classes (via partial classes) rather than generating many unwanted entitynameValidator classes. Other tables or situations seem more suited to the use of validator classes, which could be created on an 'as required' basis. Is this a viable way of proceeding, what are other people doing?

Sorry if it's obvious, but I have a very significant step up ahead and I need to make sure that I understand.

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Feb-2007 07:54:32   

Is the implication of this simply, that storage of validation logic in a separate validator class is still a valid option, but that one would need to explicitly create this validator class (if one did not choose to generate validator classes per entity)?

Yes

i.e. In my situation a significant number of tables are lookups with simple validation rules which could be handled by adding validation logic to the entity classes (via partial classes) rather than generating many unwanted entitynameValidator classes. Other tables or situations seem more suited to the use of validator classes, which could be created on an 'as required' basis. Is this a viable way of proceeding, what are other people doing?

Yes, you can also use one custom validator class to validate more than one entity.