Validation and SetNewFieldValue

Posts   
 
    
SamRose
User
Posts: 20
Joined: 24-Jun-2008
# Posted on: 27-May-2009 18:14:41   

Hello all,

I've added a validation class to my entity and it works well. But what I don't want to have to do is the database validation that is already built into LLBLGEN.

For example character length of a field or if null etc etc...

Now this is done by LLBLGEN, but I don't know how to incorporate this into my validation class?

Reading the extract from the help file, it says the following

Entity field validation, which is triggered by SetNewFieldValue(), sets the field error if an exception occurs or when the custom field validator fails. The error message is appended to an existing message.

So I was wondering how to use this in my

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

rdhatch
User
Posts: 198
Joined: 03-Nov-2007
# Posted on: 27-May-2009 18:21:13   

Hi Sam,

As I understand it, Custom Validators simply override the default LLBLGen validators (field length, null, etc.) inherited from the base class. You should be able to simply call myBase.VALIDATORNAME to call the base class' default validators. Of course, this would be done from within a partial class.

Perhaps someone can help you with the Validator class / DI configuration.

Hope this helps!

Ryan

SamRose
User
Posts: 20
Joined: 24-Jun-2008
# Posted on: 27-May-2009 18:23:39   

Hi Ryan,

Thank you for the info, I'm now going to try this...


 Public Overrides Function ValidateFieldValue(ByVal involvedEntity As SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore, ByVal fieldIndex As Integer, ByVal value As Object) As Boolean
        Dim toValidate As myEntity = CType(involvedEntity, myEntity)

        If MyBase.ValidateFieldValue(involvedEntity, fieldIndex, value) Then
            Return MyBase.ValidateFieldValue(involvedEntity, fieldIndex, value)
        Else
            Throw New ORMEntityValidationException("field", toValidate)
        End If

    End Function

or something like that...my heads spinning simple_smile

vm0112
User
Posts: 5
Joined: 15-Jun-2018
# Posted on: 24-Oct-2018 19:03:18   

@SamRose I am working on a similar solution. Did this work out for you or is there a better solution than this?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Oct-2018 07:08:13   

vm0112 wrote:

@SamRose I am working on a similar solution. Did this work out for you or is there a better solution than this?

Hi

This is a very very old thread, we recommend and encourage to not reopen old conversations, instead you could create a new thread and tell us about your concerns and how can we help. Also provide relevant information (ref...).

David Elizondo | LLBLGen Support Team