About the Vehicle Models Entity Year Field Sample Validation Script
This field's validation script enforces a business rule that only allows only vehicle models between 10 years old and 1 year greater than the current year to be added to the system. It compares the current year against the value entered in the record's Year field.
Within the context of the sample application, this requirement is defined in BPR7: Prevent Older Model Vehicles from Entering Fleet and the implementation is described in About the Data Quality Design for the Sample Application.
The full text of the script appears below:
' DEMO VALIDATION SCRIPT FOR MOTOR LOANER VEHICLE TRACKING SYSTEM ' ---------------------------------------------------------------------------------------------------------------------- ' This script enforces the business rule that only allows for ' vehicles to have the Year field between 10 years old to 1 year ' greater than current Dim iCurrentYear As Integer = System.DateTime.Now.Year Dim iEnteredValue As Integer = CInt(geRecord.GetValue("Year")) If iEnteredValue < iCurrentYear-10 Then ' Validation Failed: Entered Value is Less than the Lower Bound for this Field: Its greater than 10 years old. oResult.Success = False oResult.Message = "Year must be greater or equal to " & (iCurrentYear-10).tostring ElseIf iEnteredValue > iCurrentYear + 1 Then ' Validation Failed: Entered Value is Greater Than the Current Year + 1 Year oResult.Success = False oResult.Message = iEnteredValue.ToString & _ " is more than a year past the current year (" & _ iCurrentYear.ToString & ") and is not allowed." Else ' Year is between the current year - 10 and the current year +1, ' so allow the validation process to continue by setting the ' result to True oResult.Success = True End If
Copyright © 2014-2017 Aptify - Confidential and Proprietary