v3 - adapter, disable a few field validation for specific entity

Posts   
 
    
miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 16-Nov-2010 15:47:06   

Hi,

let say that we have entity class A with a few columns: a, b, c, d, e. Is it possible to disable field validation for a and c columns (b,d and e should be validated) for a specific class instance (other instances should has all fields validated) ?

Best Regards, MiloszeS

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 16-Nov-2010 21:48:08   

What sort of validation do you mean - the basic sort which checks field lengths etc, or validation provided by the IValidator framework interface ?

Matt

miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 17-Nov-2010 08:56:14   

I need to disable basic check - string lenght validation. I have a case in which I need to deserialize data from XML, then it's fixed by the user and after that saved into a db.

MiloszeS

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 17-Nov-2010 09:43:01   

The built-in validation is either switched on or off, or off when a validator for the entity is present.

So there is no finer selection of the fields to be validated.

What you can do is, use the 3rd option BypassWhenValidatorPresent. By adding the following to the application config file:

<add key="scaleOverflowCorrectionActionToUse" value="2"/>

Then you should use a validator for the entity which have these special fields. Inside the validator you should perform the basic (should have been) built-in validation on the rest of the fields.

This way built-in validation will be triggered for entities which have no validator assigned, and in this specific entity, no built-in validation is triggered, but you workaround this by validation the fields yourself (i.e. in the validator class).

miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 17-Nov-2010 11:47:07   

Great, it's perfectly resolves my code problem.

Regards, MiloszeS