Menu

Chapter 13 - Data Validation, IsValid and InternalIsValid

Diego Lunadei

LunaORM provide an automatic Data Validation for basic data control.

Every class save Entity to database call first entityclass.IsValid() function (a bool function). This function is in UserClass Folder so you can add to this method your own business logic validation.

This function have a structure similar to:

Public Overrides Function IsValid() As Boolean Implements ICatLav.IsValid

'RETURN TRUE IF THE OBJECT IS READY FOR SAVE
'RETURN FALSE IF LOGIC CONTROL FAIL
'INTERNALISVALID FUNCTION MADE SIMPLE DB CONTROL
Dim Ris As Boolean = InternalIsValid
'PUT YOUR LOGIC VALIDATION CODE HERE

Return Ris

End Function

InternalIsValid is a function that check for data validation based by table field properties, Max Length, Null values ecc ecc

So if you want to add other check for data you have only to make some like this:

If (my custom condition about this class is not ok) then Ris = false

or if you want to optimize better

If Ris = true AndAlso (my custom condition about this class is not ok) then Ris = false

In this mode when you exit from IsValid Function you are sure that all check condition is ok if Ris is equal to True


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.