Single Instance of Validation Logic

Learn how to manage validations on various sections of your application with minimal effort.
- Jason Moore of Light Speed Solutions

July 15, 2009
Iron Speed Designer V6.X

Introduction

Over the years I have successfully designed a large number of Iron Speed Designer applications, many of which were highly customized to meet the client’s original specifications. However, individual project requirements evolve over time and managing validations on various sections can become quite a task.

For example, if you have an Add Page and an Edit Page for a Customer table, you can add validation logic to your pages with a simple code customization. But you must repeat the customization for the AddCustomerPage.aspx and EditCustomerPage.aspx pages. In addition, if you use the classes for the table, you might need to write code to add or edit records using CustomerTable and CustomerRecord classes.

Solution

To avoid the two scenarios above, simply write your validation logic in the Business Layer. The Business Layer allows you to access all the fields of a record while you write your logic for record level validation.

Please see the screen below for the location of the Business Layer in the hierarchy:


As shown above, Iron Speed Designer generates the Business Layer for every table. Each table has two classes in the Business Layer, namely the Record Class and the Table Class.

Since you are writing validation logic for Record validation, select the Record Class and then click on the Code Documentation tab on the right panel to display additional detail as shown below:



The documentation shows there are two methods, SavingData and SavedData, which can be overridden before and after the record has been saved.

If you wish to write your validation routine at a single place, you can write it in this section. Unfortunately, at this time, the only way to write code in this section is to use Visual Studio or Notepad outside of Iron Speed Designer.

Example

Imagine you need to validate that the Customer Name is at least ten characters.

First, open your project in Visual Studio and expand the App_Code folder:


There are two sections for each class in each table, one with a Base and one without. You will work on the class without the Base, for example: CustomerRecord.vb.


Select the CustomerRecord Events and then select SavingRecord Method.


Then open the files in Microsoft Visual Studio. A new override section, like the one highlighted below, will appear.


You can write your validion logic there:


Conclusion

Write validation logic in the Business Layer in Iron Speed Designer. This allows you to manage validations on various sections of your application with minimal effort.

About the Author

Jason graduated from Nassau Community College with Bachelors of Science degree in Computer Information Systems. For the last ten years, Jason has developed applications with various programming languages such as Java, C++, VB, SQL, JavaScript, CSS, VB.NET, and C#.

Jason is so enthusiastic about Iron Speed Designer that he now refuses to create an application without it. He feels all application development is possible using Iron Speed Designer.



  Privacy Statement