Inputvalidation
With the input_validation
you can validate how data is created.
Input validation allows you to make sure the data being entered will correspond to the expected outcome, without the need to build an additional check (an indicator check e.g.).
Input validation is so-called "live validation", the user does not need to press enter or save, the validation happens before the value is stored in the database. This is one of the advantages of using input validation as opposed to running a check with a separate indicator, for which the user would first need to store the value in the template before we can check it.
A clear example of this, would be an input that should only allow positive values. First, that specific input validation needs to be created with the input_validation
tag:
{% input_validation 'validation_positive_values' min:0 %}
With above logic, you are creating specific input validation, called validation_positive_values
in which values can only be positive ( min:0
). If such data (positive values) is not created (e.g. a negative value is being created), it will unreconcile the template in which the input gets created.
Validation
Once the input validation has been created, you can apply it to certain inputs by using the newly created input_validation
variable with the validation
attribute in your input statement:
{% input_validation 'validation_positive_values' min:0 %}
{% input custom.depreciation.value as:currency validation:validation_positive_values %}
It will result in the following output, if one enters a negative value:

The user is made aware of the incorrect data, while the template becomes unreconciled as a result.
Input validation has a clear benefit, not only from a UX perspective (as users can more easily see where incorrect data is entered), but also because it avoids building additional indicator checks in Liquid.
Min and max numeric validation
Using the min
and max
attributes for integer and decimal data types.
{% input_validation 'numeric_validation' min:0 max:10 %}
{% input custom.example.numeric_validation as:currency validation:numeric_validation %}
The code example above will produce the following output in the template:

Min_exclusive and max_exclusive numeric validation
Using the min_exclusive
and max_exclusive
attributes for integer and decimal data types. In contrast to min
and max
validation, min_excluse
and max_exclusive
exclude the minimum/maximum value. This comes in handy when you want to validate the input to positive or negative values only (excluding zero).
{% input_validation "strict_range" as:numeric min_exclusive:0 max_exclusive:100 %}
{% input custom.example.value_strict as:integer validation:strict_range %}
The code example above will produce the following output in the template:

A more detailed description of the
min_exclusive
andmax_exclusive
attributes can be found in the following Community CASE
Date validation
Using the start_date
and end_date
attributes for date data types.
{% input_validation 'date_validation' start_date:"2022-01-01" end_date:"2022-12-31" %}
{% input custom.example.date_validation as:date validation:date_validation %}
The code example above will produce the following output in the template:

String length validation
Using the min_length
and max_length
attributes for string data types.
{% input_validation 'string_validation' min_length:2 max_length:10 %}
{% input custom.example.string_validation as:text validation:string_validation %}
The code example above will produce the following output in the template:

If input validation is shared across several templates within the same workflow, it can easily be created in a shared part and used anywhere.
Multiple Validations
You can add more than one validation to a single input by listing them in an array. This will be particularly useful once we introduce regex validations in the future.
{% input_validation min_length_val min_length:1 %}
{% input_validation max_length_val max_length:5 %}
{% assign len_validations = "min_length_val,max_length_val" | split:"," %}
{% input custom.some.value_str validation:len_validations %}
Updated 4 days ago