Data Validation

The Data Validation framework dynamically validates the data you enter in a field, based on the associated set of business rules. These business rules are defined as configurations in the Spotlight app. The Data validation framework is an efficient tool that enables easy validations without the need to re-compile the Infinity Onboarding app.

Broadly, the input data can be validated for the following conditions:

  • Mandatory checks: It specifies if the input data is mandatory for a field.
  • Value checks: It verifies the input data that you enter in a field. The value checks can be categorized into the following:
    • Length: It enables you to set the minimum and maximum length to the input data. For example, Name length – Min-3, Max-30
    • Limit: It enables you to set the minimum and maximum limits for the input data. For example, Minimum age limit -18
    • Format: It enables you to verify if the input data follows a specified format. For example, format of an Email or a Name.
    • Regex: A custom regular expression. For example, pattern specifications for a password

The fields in the client app can be associated with business rules by using the concept of Field Rule Mapping, to validate the input data. The Data Validation framework validates the data after you input it and it gets triggered when you click the Continue button. Furthermore, the framework uses a universal and single error message, displaying messages one at a time. If the input data in a field contains more than one error after validation, the framework displays the first error message. On the subsequent click of the Continue button, the second error message is displayed.

DATA_VALIDATION_NUO is the configuration key used for field rule mapping in the Onboarding app. This rule mapping can be modified by a system administrator by associating different rules to the fields, based on the requirement. The mapping contains the field name as key and rule set as the value. For example, in the following code, FirstName (key) is the field name, and the FIRSTNAME (value) is the associated rule.

Key Value
DATA_VALIDATION_NUO
{
    "PersonalInfo": {
        "FirstName": "FIRSTNAME",
        "LastName": "LASTNAME",
        "Age": "MINOR_AGE",
        "Email": "EMAIL",
        "MobileNumber": "MOBILE_NUMBER"
    },
    "IdentityInfo": {
        "IdNum": "ID_ALPHANUMERIC",
        "IssuedCountry": "NAME",
        "IssuedState": "NAME"
    },
    "AddressInfo": {
        "Country": "NAME",
        "State": "NAME",
        "Zipcode": "ZIPCODE"
    }
}, 
   

Here, the value contains key value pairs for each field in the Personal information and Address and Identity Details screens.

The value for each key related to a specific field can be in the following format:

  • String: You can associate a pre-defined common ruleset to a field. For example: “FirstName”: “FIRSTNAME”.
    For more information on the pre-defined rulesets, refer to Common Rule Set.
  • JSON Array: You can provide your own custom rule set to a field. Custom rules can be added to a field in the following format:
    "Field Name": [{
        BusinessRuleType: "", //Specifies the type of rule validation classifications. Eg: Length, Regex
        BusinessRule: "", //Specifies additional necessary information for the rule type. 
    }]        

    For more information, see Supported Custom Rules.

Common Rule Set

{
    "MANDATORY": [{
        "BusinessRuleType": "MANDATORY",
        "BusinessRule": ""
    }],

    "NAME": [{
        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_NAME"
    }],

    "ID": [{
        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_ID"
    }],

    "ID_ALPHANUMERIC": [{

        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_ALPHANUMERIC"
    }],

    "BOOLEAN": [{
        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_BOOLEAN"
    }],

    "ZIPCODE": [{
        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_NUMBER"
    }, {
        "BusinessRuleType": "VALUE_LENGTH",
        "BusinessRule": "MIN=5,MAX=10"
    }],

    "FIRSTNAME": [{
        "BusinessRuleType": "MANDATORY",
        "BusinessRule": ""
    }, {
        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_NAME"
    }, {
        "BusinessRuleType": "VALUE_MIN_LENGTH",
        "BusinessRule": "3"
    }, {
        "BusinessRuleType": "VALUE_MAX_LENGTH",
        "BusinessRule": "50"
    }],

    "LASTNAME": [{
        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_NAME"
    }, {
        "BusinessRuleType": "VALUE_MIN_LENGTH",
        "BusinessRule": "3"
    }, {
        "BusinessRuleType": "VALUE_MAX_LENGTH",
        "BusinessRule": "30"
    }],

    "WORKING_AGE": [{
        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_NUMBER"
    }, {
        "BusinessRuleType": "VALUE_MIN_LIMIT",
        "BusinessRule": "18"
    }, {
        "BusinessRuleType": "VALUE_MAX_LIMIT",
        "BusinessRule": "58"
    }],

    "MINOR_AGE": [{
        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_NUMBER"
    }, {
        "BusinessRuleType": "VALUE_MIN_LIMIT",
        "BusinessRule": "18"
    }],

    "AGE": [{
        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_NUMBER"
    }, {
        "BusinessRuleType": "VALUE_LIMIT",
        "BusinessRule": "MIN=1,MAX=130"
    }],

    "NUMBER": [{
        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_NUMBER"
    }],

    "EMAIL": [{
        "BusinessRuleType": "MANDATORY",
        "BusinessRule": ""
    }, {
        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_EMAIL"
    }],

    "MOBILE_NUMBER": [{
        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_NUMBER"
    }, {
        "BusinessRuleType": "VALUE_MIN_LENGTH",
        "BusinessRule": "6"
    }, {
        "BusinessRuleType": "VALUE_MAX_LENGTH",
        "BusinessRule": "10"
    }],

    "DATE": [{

        "BusinessRuleType": "VALUE_FORMAT",
        "BusinessRule": "FORMAT_DATE"
    }]
}

Supported Custom Rules

The list of supported rules for each kind of data validation is as follows:

Mandatory

Rule for any mandatory field validations.

{
    "BusinessRuleType": "MANDATORY",
    "BusinessRule": ""
}
//does null and empty checks on server(java) 
//does null, undefined and empty checks on client(javascript) 
   

Value Length Rules

Rules for any length validations.

//validates min length 
{
    "BusinessRuleType": "VALUE_MIN_LENGTH",
    "BusinessRule": "3"
}

//validates max length 
{
    "BusinessRuleType": "VALUE_MAX_LENGTH",
    "BusinessRule": "50"
}

//validates both min and max lengths 
{
    "BusinessRuleType": "VALUE_LENGTH",
    "BusinessRule": "MIN=3,MAX=30"
}
 

Value Limit Rules

Rules for any limit validations.

//to be used only for number fields 
//validates min limit 
{
    "BusinessRuleType": "VALUE_MIN_LIMIT",
    "BusinessRule": "18"
}

//validates max limit 
{
    "BusinessRuleType": "VALUE_MAX_LIMIT",
    "BusinessRule": "58"
}

//validates both min and max limits 
{
    "BusinessRuleType": "VALUE_LIMIT",
    "BusinessRule": "MIN=18,MAX=58"
}
  

Value Format Rules

Rules for common formats like Name, Email, etc

//Name format validation -  
// Validates names in all Locales (Languages) 
{
    "BusinessRuleType": "VALUE_FORMAT",
    "BusinessRule": "FORMAT_NAME"
}

//Email format Validation 
{
    "BusinessRuleType": "VALUE_FORMAT",
    "BusinessRule": "FORMAT_EMAIL"
}

//Number format Validation 
{
    "BusinessRuleType": "VALUE_FORMAT",
    "BusinessRule": "FORMAT_NUMBER"
}

//ID format validation(ISO codes, SSN, other IDs) 
//Accepts A-Z, a-z, 0-9, hyphen 
{
    "BusinessRuleType": "VALUE_FORMAT",
    "BusinessRule": "FORMAT_ID"
}

//AlphaNumeric format Validation 
{
    "BusinessRuleType": "VALUE_FORMAT",
    "BusinessRule": "FORMAT_ALPHANUMERIC"
}

//Boolean Validation 
{
    "BusinessRuleType": "VALUE_FORMAT",
    "BusinessRule": "FORMAT_BOOLEAN"
}

//Date Format Validation 
//Accepts character string of length 6 to 10, containing only the combination of 0123456789.-/ 
//i.e., only numbers and 3 special characters(dot,hyphen,forward slash) 
{
    "BusinessRuleType": "VALUE_FORMAT",
    "BusinessRule": "FORMAT_DATE"
}

Regex Rules

Rule format for any regex validations.

// Validates any custom regex 
{
    "BusinessRuleType": "VALUE_REGEX",
    "BusinessRule": "<custom Regex>"
} 

Here is an example of custom regex for the Email Address field.

"Email": [{
    "BusinessRuleType": "VALUE_REGEX",
    "BusinessRule": "^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[c][o][m]$"
}]

The above business rule ensures that every username which contains any characters besides a-z, A-Z, or 0-9, and special characters besides full stop(.), underscore(_), and hyphen(-) after that will be considered invalid. Also, it ensures that the email addresses containing the domain names ending with .com are the only valid ones.

NOTE: Only the above-mentioned BusinessRuleTypes are supported by the data validation framework, but you can use any combination of those business rule types to form a ruleset.


Bookmark Name Actions
Feedback
x