Validation, dependency injection

Posts   
 
    
JoeyM
User
Posts: 15
Joined: 07-Aug-2012
# Posted on: 30-Oct-2012 17:09:13   

Hello Guys,

I have a relatively simpel question, im using the validation dep. injection.

I don't want to call the "return base.ValidateFieldValue(involvedEntity, fieldIndex, value);" because it generatos not friendely error messages for my users.

My question is, when i do not call this method, do i need to check if the "object value" wich is passed through the "public override bool ValidateFieldValue()" method, also is correct for the given data type? and also is within the given length boundaries (for strings and int's etc) or is this already done by the frame work before this method is called en will this never be a problem?

In het Validor base a read the text "after the value has passed validation for destination column type and null values"

Just to make sure that i ask my question straight, if i have a datetime field "startdate" in my database, and some idiot inputs a date time in a textbox that is not a parseable date time, (via data binding) what happens?

Regards, Joey

// Summary: // Validates the given EntityFieldCore object on the given fieldIndex with the // given value. This routine is called by the Entity's own value validator // after the value has passed validation for destination column type and null // values.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 30-Oct-2012 18:29:54   

You can configure your app to bypass the buil-In validation. Please check: Bypassing built-in validation logic

In general the built-In Validation should be used as your last line of defence. Having said that, you should have UI/Input validation. That displays user-friendly messages.

JoeyM
User
Posts: 15
Joined: 07-Aug-2012
# Posted on: 30-Oct-2012 20:08:03   

Walaa wrote:

You can configure your app to bypass the buil-In validation. Please check: Bypassing built-in validation logic

In general the built-In Validation should be used as your last line of defence. Having said that, you should have UI/Input validation. That displays user-friendly messages.

Hello,

So what you say is that if i completly by-pass the LLBLgen validation logic, i have to build it all myself? Is there no way i can customize messages myself in any other way?

regards, Joey

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 31-Oct-2012 06:14:30   

JoeyM wrote:

So what you say is that if i completly by-pass the LLBLgen validation logic, i have to build it all myself? Is there no way i can customize messages myself in any other way?

Hi Joey, you could catch when the entity is set back from the UI, and look for ORMFieldIsReadonlyException, ORMValueTypeMismatchException or ArgumentOutOfRangeException and show your own error.

You also could use BuildInValidationBypass.BypassWhenValidatorPresent, so the validation is bypassed only when you are using your own validator. Then you could implement your own "OnValidateFieldValue", the routine is small and you can check it on the ORMSupportClasses source code, in case you want to implement it by yourself.

David Elizondo | LLBLGen Support Team