Validation

Posts   
 
    
SamRose
User
Posts: 20
Joined: 24-Jun-2008
# Posted on: 28-May-2009 16:19:50   

Hello all,

Sorry if this has been done to death, I've had a search on the forums but I'm confusing myself.

I'm applying validation on an entity.

So I've created a validator class for that entity.

<DependencyInjectionInfo(GetType(myEntity), "Validator", _
                         ContextType:=DependencyInjectionContextType.Singleton)> _
Public Class myValidator
    Inherits ValidatorBase

I've seen that LLBLGEN has a build-in validation logic that throws an ArgumentOutOfRangeException if there is an error.

I'm trying to figure out how i can inherit this build-in validation into myValidator so that i can build up a list of validation errors and display them instead of one at a time for the ArgumentOutOfRangeException ?

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 29-May-2009 11:23:22   

You can disable the built-in validation.

manual wrote:

Bypassing build-in validation logic It might be that you don't want to use the build-in validation logic and want to use your own validation logic instead. You can make LLBLGen Pro bypass the build-in validation logic using the static (Shared) property on EntityBase (if you're using SeflServicing) or EntityBase2 (if you're using Adapter) called BuildInValidationBypassMode. Set that property to any of the BuildInValidationBypass values, which are NoBypass (value 0, default), AlwaysBypass (value 1) or BypassWhenValidatorPresent (value 2). If you choose to use AlwaysBypass and there's no validator present no validation on the field will be performed. You can also set this property through the application's config file by adding this line to the appSettings section of your application's config file:

<add key="buildInValidationBypassMode" value="0"/>

Where value is one of the values 0, 1 or 2 for resp. NoBypass, AlwaysBypass or BypassWhenValidatorPresent.

SamRose
User
Posts: 20
Joined: 24-Jun-2008
# Posted on: 29-May-2009 11:26:12   

Sorry I don't think I made myself clear...

I want to inherit the built-in validation into my own validation class.

So I can throw the exception when it is out of range in my class building up a list of errors.

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 29-May-2009 11:30:05   

I don't think there is a way to do that.

SamRose
User
Posts: 20
Joined: 24-Jun-2008
# Posted on: 29-May-2009 11:33:19   

So I'd have to create my own database structure validation rules for the length and format of each field in my custom class...

no worries, just a shame as the functionality is already written in LLBLGEN.