You can customize a request form to ensure that users provide valid values at request time by adding constraints to fields or using an external validation source.

Some field properties, such as minimum, maximum, regular expressions, match fields, or not empty, can be configured with constraints to ensure valid values. See Custom Form Designer Field Properties.

External validation checks for valid values from an external source using vRealize Orchestrator actions .

Some examples where you might use external validation includes:

  • The valid values are defined in an external source. For example, vRealize Orchestrator.

  • The validation must affect several fields. For example, a vRealize Orchestrator action collects the disk size and storage pool capacity, and validates the provided size values based on available space.

How do you order multiple external validations in one blueprint? The validations are processed in the order that the appear on the External Validation canvas. If you have two validations that validate the same field, the second validation results will overwrite the first. To reorder the validations, you can click and drag the cards on the canvas.

vRealize Orchestrator User Example

In this use case, you want the catalog user to provide only a new user name. To do this example, you have a vRealize Orchestrator action that checks whether the user name provided in the form exists in your Active Directory database. If the name does exist, an error message appears on the request form.

This use case is applied to the Create a Custom Request Form with Active Directory Options example.

  1. In vRealize Orchestrator, configure an action, checkIfUsernameExists, with a script similar to the following example.



    Use the following as a script example. In this example, return is the message that appears if the validation fails.

    if (!username) {
    	return "";
    }
    
    var result = ActiveDirectory.search("User", username);
    
    if (result && result.length > 0) {
    	return "Username '" + username +"' already exists.";
    }
    
    return "";

  2. In vRealize Automation, open the custom form designer for your blueprint, click External Validation, and drag the Orchestrator validation type onto the canvas.

  3. Configure the external validation options.



    • Validation label = Check if user name exists

    • Select action = <your vRealize Orchestrator actions folder>/checkIfUsernameExists

    • Action inputs

      • username = Field and Username

    • Highlighted fields

      • Click Add Field and select Username.

A field-level validation error appears in the catalog request form if the entered valued fails validation. If you want a global error, do not configure the highlighted field.

vRealize Orchestrator Multiple Fields Example

In this use case, you want to base the validation of the CPU, memory, and storage values on the project value. For example, if the users select the Dev project, then the maximum number of CPUs is 4. If they select Prod, then the maximum value is 2.

For this use case, add a project field to the Create a Custom Request Form with Active Directory Options example. Configure project as a drop-down with Dev and Prod.

  1. In vRealize Orchestrator, configure an action, validateMachineWithUserForm, with a script similar to the following example.



    Use the following as a script example for the CPU checking. Continue adding the memory and storage values to the script, as needed. In this example, return is the message that appears if validation fails.

    if (project ==='dev'){
    	if (cpu > 4){
    		return "Number of CPUs limit for project vRA is 4";
    	}
    }
    
    if (project==='prod'){
    	if (cpu > 2){
    		return "Number of CPUs limit for project vRA is 2";
    	}
    }
    
    return "";

  2. In vRealize Automation, open the custom form designer for your blueprint, click External Validation, and drag the Orchestrator validation type onto the canvas.

  3. Configure the external validation options.



    • Validation label = Validate machine details

    • Select action = <your vRealize Orchestrator actions folder>/validateMachineWithUserForm

    • Action inputs

      • cpu = Field and Number of CPUs

      • memory = Field and Memory (GB)

      • storage = Field and Storage (GB)

      • Project = Field and Project

    • Highlighted fields

      • Click Add Field and select Project.

In the catalog, your catalog user might see a validation error similar to the following example.