Parameter Validation

Validation rules can be created for two main types of parameters:

  1. Inbound API Parameters (Request Parameters): These are parameters passed to APIs as part of the inbound request.
  2. Response Parameters from Connectors in Orchestration (Response Parameters): These are parameters generated as responses from connectors within an orchestration.

Depending on the type of parameter, various types of validation are available.

Hash is described in the GLU Functions & Formulas article.

Min/Max Length

The min/max length validation applies to text parameters, specifying the acceptable character length, and to numeric parameters (integer or float), defining the allowable number of digits.

Here’s how it works:

  • If the min length is left null, only the max length is enforced.
  • If the max length is left null, only the min length is enforced.

Example:

Suppose we set Min = 2 and Max = 4:

  • “hello world” would fail as it exceeds the max length of 4 characters.
  • “h” would fail as it falls short of the min length of 2 characters.
  • “hell” would pass as it falls within the range of 2 to 4 characters.
  • Integer “232” would pass as it falls within the range of 2 to 4 digits.
  • Integer “23” would pass as it matches the min length of 2 digits.
  • Integer “2324” would pass as it matches the max length of 4 digits.

Example Use Case:

You could validate the length of an incoming parameter to route it to a specific action based on its length. To achieve this, you can create a Derived Parameter to calculate length then add a Handler to route based on the Derived Parameter value (i.e. length). In this case, the Derived Parameter formula might look like this: ${token_num}.length()

Min/Max Value

The min/max value validation applies to numeric parameters, specifying the acceptable range of values.

Here’s how it works:

  • If the min value is left null, only the max value is enforced.
  • If the max value is left null, only the min value is enforced.

Example:

Suppose we set Min = 2 and Max = 4:

  • Integer “27” would fail as it exceeds the max value of 4.
  • Integer “1” would fail as it falls short of the min value of 2.
  • Integer “3” would pass as it falls within the range of 2 to 4.
  • Integer “2” would pass as it matches the min value of 2.
  • Integer “4” would pass as it matches the max value of 4.

Regex

Regex (regular expression) validation allows you to define complex patterns for parameter values using regular expressions.

Here’s how it works:

  • Enter the regular expression pattern into the regex field.
  • You can use online resources like regex cheat sheets or testers to build and test your regular expressions before configuring them in the validation.

Example:

Suppose we set RegEx (Alpha Only) as [a-zA-Z]*:

  • String “hello_world” would fail as it contains a special character.
  • String “hello2” would fail as it contains a number.
  • String “helloWorld” would pass as it contains only letters (alpha only).

Date Format


The format field should be used to set the required date format for the parameter.

For instance, if the date format is set to dd-mm-yyyy:

  • If “23-OCT-2019” is passed in as a date, it would not pass the validation, and an error would be raised.
  • However, if “23-10-2019” is passed in as a date, it would pass validation.

Date formats adhere to the ISO 8601 standard. The recommended date format is “2012-04-23T18:25:43.511Z”.

It is recommended to ensure date formats used:

  1. Human-readable yet succinct: Choose formats that are easy for humans to interpret at a glance but also compact to save space and improve readability.
  2. Sorting order: Opt for formats that allow for correct sorting, ensuring that dates are arranged chronologically when sorted alphabetically.
  3. Include fractional seconds: Incorporate fractional seconds whenever possible, as this can aid in accurately establishing the chronology of events, especially in high-frequency systems.
  4. Compliance with ISO 8601: Ensure that the chosen date formats conform to the ISO 8601 standard, which provides a globally recognized and standardized format for representing dates and times.

For a more detailed view of date formatting please refer to GLU Formulas & Functions

Image

For an image parameter, setting a default value means that if no image base64 value is provided for the parameter, the default base64 value will be used instead.

This base64 image decoder can be used to extract a base64 image string.

All data types have a default value field, which can be set if the parameter is passed in without a value set.

Default

The default value needs to adhere to the data type it configures and needs to adhere to the validation rules applied.

Required

All validation rules include a Boolean option to indicate whether the field is required or not

If the Required checkbox is checked, default values cannot be entered. This means that if a parameter is marked as required and no value is provided for it, the validation will fail.

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support
Fill the form and we’ll contact you shortly

    I agree with

    cookies
    We uses cookies to make your experience on this website better. Learn more
    Accept cookies