vRO Input Validation

Since vRA 6.x released, XaaS use cases are very common (here some cool demo for create MS Active Directory user as a service).

But presenting workflows to end users required some rethinking and redesign the user form so it will be user friendly with minimum ״free text” that can cause an error during the workflow runtime.

You can do some input validation in vRA, but also in vRO. In the following post I’ll show you how to do input validation in vRO.

vRO Workflow Presentation Tab

vRO Workflow Presentation Tab

For basic validation like IP Address or Hostname (FQDN), you can leverage the out of the box internet address validation for strings only:

Property Type – Valid Internet Address

Value – Hostname or IP Address/Hostname/IP Address/IPv4 Address/IPv6 Address

Screenshot 2015-04-27 12.57.57

Internet Address Validation for String object

Other option, is to use regular exception for single string object:

Property type – Matching Regular expression

Value – ^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$

Screenshot 2015-04-27 13.06.21

IP Address Validation using regular expression

Another example, validate email address:

Property type – Matching Regular expression

Value – ^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$

Screenshot 2015-04-27 13.13.50

Email Address Validation using regular expression

You can also limit the string length using this two properties:

  • Maximum string length
  • Minimum string length

For number you have 3 out of the box validation:

  • Number Format (##.###)
  • Maximum number value
  • Minimum number value

Very limited, but you can have string object as an input and create regular expressions that will except numbers only (ugly workaround, ha?)

So this all about strings or numbers, right? how about other objects or cross-input parameters validation?

In this case, we will have to use “Custom Validation”. Custom Validation property can run an action that will validate the user input, here his the official definition from VMware vRealize Orchestrator documentation:

If the OGNL expression returns a string, the validation shows this string as the text of the error result.

Straight forward – the action will return anything other than string when the input is valid, and a string with the error message in case that the input is invalid.

You can use Custom Validation property almost on every vRO object, so it can help you make sure in case that the input parameter is not string object or regular expression isn’t enough.

Very simple example – let’s say that the user can choose the name of the virtual machine, so we need to verify that this name isn’t already in use.

This is the input and the output for our action:

Action input / output

Action input / output

The action code:

  1. var vms = VcPlugin.getAllVirtualMachines();
  2. for each (var vm in vms) {
  3.     if (vm.name == vmname) {
  4.         return “The Virtual Machine Name “+vmname+” is already in use”;
  5.     }
  6. }
  7. return true;


In the presentation, the custom validation property is set like this:

Custom Validation Using Action

Custom Validation Using Action

Note: the “#vmname” is the input parameter, don’t forget to set it.

Now, when the user will enter the virtual machine name during the request process he will get the following error:

Kind of user friendly error during the request

Kind of user friendly error during the request

And here you go, live validation during the request… But! Keep in mind that complex validation scenarios has direct impact , from performance perspective, on the end-user experience.

I hope that you will find it useful!


One thought on “vRO Input Validation

  1. Thanks for post, it’s very useful.

    I wanna ask you something about this topic. Can we return a string that will be shown on input screen like in your sample but without error? So, I want to show a sentence that contains vmname but it won’t be an error message.

Leave a Reply