Extension for Mandatory Field Validations
This doc explains how to customize a mandatory field to make it an optional field. Consider the Last Name field in the Personal Information module. It is a compulsory field. To make it an optional field, you must configure the following:
To customize a field to make it mandatory or optional, you need not make any changes on the server side. The spotlight configurations are fetched and validated by Java services.
Client Application Extensions
To make a mandatory field an optional field, you must create a Form Controller Extension of the Form associated with the field and override the required functions. In this case, you must extend the frmPersonalInfo form controller. To do so, follow these steps in your Temenos DigitalOrigination Visualizer Project.
- In Project explorer, expand the Modules section.
- Right-click the require tab and select the New Require module to create a new JS file.
- Rename the JS file to
PersonalInfoControllerExtn
. - Define a new function in the extension file to override the implementation of the original function.
- Original Function:
isPersonalInformationValid: function() { var firstName = this.view.UserInformation.atbxFirstName.tbxAnimatedKA.text.trim() == "" ? false : true; var lastName = this.view.UserInformation.atbxLastName.tbxAnimatedKA.text.trim() == "" ? false : true; var email = this.view.UserInformation.atbxEmail.tbxAnimatedKA.text.trim() == "" ? false : true; var dob = this.view.UserInformation.DateInput.getText().length === 10 ? true : false; return firstName && lastName && email && dob; },
- The function to be defined in the
PersonalInfoControllerExtn
file is as follows.isPersonalInformationValid: function() { var firstName = this.view.UserInformation.atbxFirstName.tbxAnimatedKA.text.trim() == "" ? false : true; // removing the check for the last name //var lastName = this.view.UserInformation.atbxLastName.tbxAnimatedKA.text.trim() == "" ? false : true; var email = this.view.UserInformation.atbxEmail.tbxAnimatedKA.text.trim() == "" ? false : true; var dob = this.view.UserInformation.DateInput.getText().length === 10 ? true : false; return firstName && email && dob && birthCountry; },
- Original Function:
- To remove the Last Name field from the data validation payload, you must define the validateFormData function in the
PersonalInfoControllerExtn
file.validateFormData: function() { if (!this.isValidDOB()) { this.view.UserInformation.lblError1.setVisibility(true); this.view.UserInformation.lblError1.text = kony.i18n.getLocalizedString("kony.nuo.PersonalInfo.enterValidDOB"); this.view.UserInformation.DateInput.flxSeparator.skin = applicationManager.getConfigurationManager().getConfigurationValue("underlineErrorSkin"); return false; } if (this.view.UserInformation.filterDropdown.getSelectedOption() === null && this.view.UserInformation.filterDropdown.isVisible == true) { this.view.UserInformation.lblError3.setVisibility(true); this.view.UserInformation.filterDropdown.flxSeperatorKA.skin = applicationManager.getConfigurationManager().getConfigurationValue("underlineErrorSkin"); this.view.UserInformation.lblError3.text = kony.i18n.getLocalizedString("kony.nuo.PersonalInfo.countryCodeError"); return false; } else { var obj = "PersonalInfo"; var dataJSON = { "FirstName": this.view.UserInformation.atbxFirstName.tbxAnimatedKA.text, //Removing LastName from data validation JSON // "LastName": this.view.UserInformation.atbxLastName.tbxAnimatedKA.text, "Age": this.isValidDOB(), "Email": this.view.UserInformation.atbxEmail.tbxAnimatedKA.text, "MobileCountryCode": this.view.UserInformation.filterDropdown.tbxDropdownKA.text ? this.view.UserInformation.filterDropdown.tbxDropdownKA.text : this.getCountryCode(), "MobileNumber": this.view.UserInformation.atxtPhoneNumber.tbxAnimatedKA.text }; var dataValidator = applicationManager.getDataValidationHandler(); var response = dataValidator.validateData(dataJSON, obj); if (Object.entries(response).length === 0) { return true; } else { this.showWidgetErrors(response); return false; } } }
- Link the new extension file to your ModuleConfig file of the Personal Information module. To do so, go to Project > Reference Architecture Extensions > PersonalInfoModule > Config > ModuleConfig.
Add the following line of code in the Forms method:"ControllerExtensions": ["PersonalInfoControllerExtn"]
Configuring Spotlight
After you define the required functions in the client application, you must delete the Last Name key from the Temenos DigitalOrigination Bundle in the Spotlight app. To do so, follow these steps.
- Open the Spotlight app.
- From the left pane, select System Configurations. The System Configurations page appears with the list of bundles.
- Open the Temenos DigitalOrigination bundle, named Retail Origination Bundle. The View Bundle page appears that contains the details of the Temenos Digital Origination keys.
- Search for the DATA_VALIDATION_NUO key and select Edit from the contextual menu. The Add Configuration window appears.
- From the Value field, remove the Last Name field and the validation rule and click Update.
- After updating the DATA_VALIDATION_NUO key, click Update on the View Bundle page.
For more information about adding configurations in the Spotlight app, click here.
The DATA_VALIDATION_NUO is as follows.
{ "PersonalInfo": { "FirstName": "FIRSTNAME", "Age": "MINOR_AGE", "Email": "EMAIL", "MobileNumber": "MOBILE_NUMBER", "CIF": "ID_ALPHANUMERIC", "DateOfBirth": "DATE", "IsExistentMember": "BOOLEAN" }, "CoApplicantCardInfo": { "FirstName": "FIRSTNAME", "LastName": "LASTNAME", "Email": "EMAIL", "MobileNumber": "MOBILE_NUMBER" }, "IdentityInfo": { "IdNum": "ID_ALPHANUMERIC" }, "AddressInfo": { "Country": "ID", "State": "ID", "Zipcode": "ZIPCODE", "City": "NAME" }, "Funding": { "DebitAccount": "ACCOUNT_NUMBER", "DebitRoutingNumber": "ROUTING_NUMBER", "FundingAmount": "AMOUNT_FORMAT" }, "UserAction": { "MonthlyGrossIncome": [{ "BusinessRuleType": "MANDATORY", "BusinessRule": "" }, { "BusinessRuleType": "VALUE_FORMAT", "BusinessRule": "FORMAT_AMOUNT" }], "StartDate": "DATE", "MobilePhoneNumberConsent": [{ "BusinessRuleType": "MANDATORY", "BusinessRule": "" }], "BackupWithholding": [{ "BusinessRuleType": "MANDATORY", "BusinessRule": "" }], "EmploymentStatus": [{ "BusinessRuleType": "MANDATORY", "BusinessRule": "" }], "Citizenship": [{ "BusinessRuleType": "MANDATORY", "BusinessRule": "" }], "ConfirmAddress": [{ "BusinessRuleType": "MANDATORY", "BusinessRule": "" }], "Age": [{ "BusinessRuleType": "MANDATORY", "BusinessRule": "" }, { "BusinessRuleType": "VALUE_FORMAT", "BusinessRule": "FORMAT_NUMBER" }, { "BusinessRuleType": "VALUE_MIN_LIMIT", "BusinessRule": 18 }, { "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": 150 }], "AlternateEmailID": "EMAIL", "MoneyOutsideUS": [{ "BusinessRuleType": "MANDATORY", "BusinessRule": "" }, { "BusinessRuleType": "VALUE_FORMAT", "BusinessRule": "FORMAT_AMOUNT" }], "USNationality": [{ "BusinessRuleType": "MANDATORY", "BusinessRule": "" }], "CityOfBirth": "NAME", "ConfirmTaxID": "ID_ALPHANUMERIC", "TimeOnCurrentAddress": "ID", "ConfirmDOB": "DATE", "IncomeDocumentCount": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "5" }], "ProofOfIncomeEmployedCount": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "5" }], "ProofOfIncomeStudentCount": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "5" }], "ProofOfIncomeRetiredCount": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "5" }], "ProofOfIncomeOtherCount": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "5" }], "DriverLicenseCount": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "5" }], "PassportCount": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "5" }], "OptionalQuestionCount": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "5" }] }, "EmployerInfo": { "OrganizationName": "ID", "Country": "ID", "State": "ID", "Zipcode": "ZIPCODE", "City": "NAME", "PhoneNumber": "MOBILE_NUMBER" }, "IncomeInfo": { "WageRate": "AMOUNT_FORMAT", "HoursPerWeek": "NUMBER" }, "IncomeDocument": { "DocumentSize": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "2" }], "DocumentName": [{ "BusinessRuleType": "VALUE_REGEX", "BusinessRule": "^[^\\s][a-zA-Z0-9 ~!@#$^&()+_'.-]*$" }], "DocumentType": [{ "BusinessRuleType": "VALUE_AMONG", "BusinessRule": "image/png,application/pdf,image/jpeg,image/jpg" }] }, "ProofOfIncomeEmployed": { "DocumentSize": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "2" }], "DocumentName": [{ "BusinessRuleType": "VALUE_REGEX", "BusinessRule": "^[^\\s][a-zA-Z0-9 ~!@#$^&()+_'.-]*$" }], "DocumentType": [{ "BusinessRuleType": "VALUE_AMONG", "BusinessRule": "image/png,application/pdf,image/jpeg,image/jpg" }] }, "ProofOfIncomeStudent": { "DocumentSize": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "2" }], "DocumentName": [{ "BusinessRuleType": "VALUE_REGEX", "BusinessRule": "^[^\\s][a-zA-Z0-9 ~!@#$^&()+_'.-]*$" }], "DocumentType": [{ "BusinessRuleType": "VALUE_AMONG", "BusinessRule": "image/png,application/pdf,image/jpeg,image/jpg" }] }, "ProofOfIncomeRetired": { "DocumentSize": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "2" }], "DocumentName": [{ "BusinessRuleType": "VALUE_REGEX", "BusinessRule": "^[^\\s][a-zA-Z0-9 ~!@#$^&()+_'.-]*$" }], "DocumentType": [{ "BusinessRuleType": "VALUE_AMONG", "BusinessRule": "image/png,application/pdf,image/jpeg,image/jpg" }] }, "ProofOfIncomeOther": { "DocumentSize": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "2" }], "DocumentName": [{ "BusinessRuleType": "VALUE_REGEX", "BusinessRule": "^[^\\s][a-zA-Z0-9 ~!@#$^&()+_'.-]*$" }], "DocumentType": [{ "BusinessRuleType": "VALUE_AMONG", "BusinessRule": "image/png,application/pdf,image/jpeg,image/jpg" }] }, "DriverLicense": { "DocumentSize": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "2" }], "DocumentName": [{ "BusinessRuleType": "VALUE_REGEX", "BusinessRule": "^[^\\s][a-zA-Z0-9 ~!@#$^&()+_'.-]*$" }], "DocumentType": [{ "BusinessRuleType": "VALUE_AMONG", "BusinessRule": "image/png,application/pdf,image/jpeg,image/jpg" }] }, "Passport": { "DocumentSize": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "2" }], "DocumentName": [{ "BusinessRuleType": "VALUE_REGEX", "BusinessRule": "^[^\\s][a-zA-Z0-9 ~!@#$^&()+_'.-]*$" }], "DocumentType": [{ "BusinessRuleType": "VALUE_AMONG", "BusinessRule": "image/png,application/pdf,image/jpeg,image/jpg" }] }, "OptionalQuestion": { "DocumentSize": [{ "BusinessRuleType": "VALUE_MAX_LIMIT", "BusinessRule": "2" }], "DocumentName": [{ "BusinessRuleType": "VALUE_REGEX", "BusinessRule": "^[^\\s][a-zA-Z0-9 ~!@#$^&()+_'.-]*$" }], "DocumentType": [{ "BusinessRuleType": "VALUE_AMONG", "BusinessRule": "image/png,application/pdf,image/jpeg,image/jpg" }] }
You can associate each field in the Spotlight app with either a rule from the common rule set or a custom rule. To create or use the rules for data validation, refer to Data Validation.
In this topic