Automatic Data Validation

From OpenPetra Wiki
Revision as of 14:30, 29 May 2012 by Christiankatict (talk | contribs) (Created page with '==Introduction== '''The term 'Automatic Data Validation' relates to Data Validation code that is automatically generated by the OpenPetra WinForms Generator.''' The WinForms Gen…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

The term 'Automatic Data Validation' relates to Data Validation code that is automatically generated by the OpenPetra WinForms Generator.

The WinForms Generator automatically creates program code...

  • in Client DLL's (in the generated C# files of Forms/UserControls),
  • in Shared DLL's and
  • in Server DLL's

...for the automatic data validation of Controls which are bound to certain DataColumns of OpenPetra DB Tables.

Scope

Automatic Data Validation code is generated only for DB Tables that are specified in the petra.xml file!

DataColumns in the petra.xml file for which automatic data validation code is generated:

  • DataColumns which are part of a Primary Key or are part of a Unique Key
    • Data Validation code enforces that NULL must never be assigned to those DataColumns.
  • DataColumns with a NOT NULL restriction (applies to any DataColumn that isn't part of a Primary Key or Unique Key)
    • Data Validation code enforces that NULL must never be assigned to such a DataColumn.
  • DataColumns of varchar/string Type
    • Data Validation code enforces that the length of the String is not exceeded.
  • DataColumns of a numeric Type
    • Data Validation code enforces that the numeric range of the Type (e.g. Int16, Int32, Decimal) and it's precision (if applicable) is not exceeded.

Multiple automatic data validations may be generated for a single DataColumn to enforce multiple rules! Example: Automatic data validation code that will be created for a varchar/string column which is part of a Unique Key: 1) code for a NOT NULL check, 2) code for a string length check.


Placement of Automatic Data Validation Code

Client DLL's

Calls to automatic data validation code contained in Shared DLL's will automatically be placed in all the appropriate places of a generated C# file of a Form/UserControl. The only requirement for this to happen is that the YAML file that specifies the Form/UserControl contains data bound Controls. Validation=true does not need to be set on Controls for that to happen - this must only be done to indicate to the WinForms Generator that manual data validation code needs to be called for a DataColumn that is bound to that Control!

Calls to the automatic data validation code always precede calls to the manual data validation code (if manual data validation code is present at all in a Form/UserControl). This allows manual data validation code to modify the TVerificationResult objects that the automatic data validation code may create, should that be necessary (e.g. to modify the standard texts that are presented to the user for).


Shared DLL's

TODO


Server DLL's

TODO