Skip to main content
Version: Next (5.0)

Validation

The validation action checks the conditions of each criterion with a value under the validation attribute. This action is related with a validate type button (see button actions).

ValidateImage

XML skeleton​

<criteria [attributes] validation="[condition to validate]" />

Validation types​

There are some kind of validation:

Value of attributeComponentDescriptionExamples
requiredAll except checkbox and radioCheck if the field has valuevalidation="{required:true}"
textText / Textarea / PasswordCheck if the value of the criteria is a text (Numbers and white spaces are not allowed)validation="{text:true}"
textWithSpacesText / Textarea / PasswordCheck if the value of the criteria is a text (Numbers not allowed)validation="{textWithSpaces:true}"
numberText / Textarea / PasswordCheck if the value of the criteria is a numbervalidation="number"
integerText / Textarea / PasswordCheck if the value is a well-formed integervalidation="integer"
digitsText / Textarea / PasswordCheck if the value is a number with only digitsvalidation="digits"
dateText / Textarea / PasswordCheck if the value is a valid datevalidation="date"
timeText / Textarea / PasswordCheck if the value is a valid time (hour, minutes and seconds)validation="time"
emailText / Textarea / PasswordCheck if the value is a valid string emailvalidation="email"
gtAll except checkbox and radioCheck if the criterion value is greater than valuevalidation="{gt:value}"
geAll except checkbox and radioCheck if the criterion value is greater or equal valuevalidation="{ge:value}"
ltAll except checkbox and radioCheck if the criterion value is lower than valuevalidation="{lt:value}"
leAll except checkbox and radioCheck if the criterion value is lower or equal than valuevalidation="{le:value}"
eqAll except checkbox and radioCheck if the criterion value is equal than valuevalidation="{eq:value}"
neAll except checkbox and radioCheck if the criterion value is different than valuevalidation="{ne:value}"
modNumeric / Date / TimeCheck if the criterion value is divisible by valuevalidation="{mod:value}"
rangeNumeric / Date / TimeCheck if the value is inside the rangevalidation="{range:{from:value, to:value}}"
equallengthText / Textarea / PasswordCheck if the text length is equal to valuevalidation="{equallength:value}"
maxlengthText / Textarea / PasswordCheck if the text length is less than valuevalidation="{maxlength:value}"
minlengthText / Textarea / PasswordCheck if the text length is bigger than valuevalidation="{minlength:value}"
checkAtLeastCheckbox / Button checkboxAssure that there is at least value checked checkboxes in the groupvalidation="{checkAtLeast:value}"
maxRepeatGrid columnsCheck that the value of the cell is not repeated more than value times in its grid column (the cell counts as one). As in AngularJS: values are compared strictly (1 is not "1"), empty values are counted, and multiple (array) cells are never flagged. An empty value skips the rule and a non-numeric one flags every value. Only the edited cell is checked again: the other rows keep their state until they are edited or the form is validatedvalidation="{maxRepeat:value}"
patternText / Textarea / PasswordCheck if the text is equal to the parametervalidation="{pattern:value}"

Validation values​

You can assign a simple static value to the validation comparator:

{eq:3}

... or you can take the value from a setting or a criterion:

{eq:{criterion:"CriterionId",type:"date"}}

These are the possible attributes on a value comparator:

Value of attributeDescriptionExamples
valueConstant value to compare withvalue:5
criterionRetrieve the value from a criterioncriterion:"CriterionId"
settingRetrieve the value from a settingsetting:"minlengthPassword"
messageLocale from message to retrieve if validation is not passedmessage:"VALIDATION_MESSAGE_CUSTOM_ERROR"
typeType of comparisontype:"type"

Comparison types​

You can define the type of the comparison, to check the values as a defined type:

TypeDescription
dateCompare as dates
integerCompare as integer
floatCompare as floats
stringCompare as strings (default)

Multiple validation​

It is possible to have more than one validation actions under a single validation attribute. To do so, it is necessary to insert the validations in a json format:

{eq:{criterion:"Field1"},ne:{criterion:"Field2"}}

There is an exception with simple validation rules that have no parameters, such as required. In this case, it's not necessary to have the rule between {} brackets:

validation="required"

If you want to combine simple rules with complex rules, you need to define it as a complex rule as well:

{required:true, maxlength:{value:6, type:"integer"}}

Fields in hidden content​

A criterion can sit in content the user does not see: a tab that is not the active one, a step of a wizard that is not the current one, or an accordion item that is collapsed. When a validate action fails, both clients (AngularJS and React) validate every criterion of the screen, hidden or not, and then bring the first invalid one into view:

  1. The tabs, wizard steps and accordion items that hide the field are opened, from the outer container to the inner one. A container that already shows the field is left as it is, and an accordion that allows several open items keeps the others open.
  2. The field is focused and scrolled into view.
  3. The tab header, the wizard step and the accordion item that hold invalid fields are marked with an error indicator (a red title with an exclamation mark, and a red number in a wizard step). The mark goes away when the fields are fixed.

The first invalid field is the first one in the order of the screen definition. Screens without hidden content keep working as they did: the error message is shown next to the field.

For automated tests, the marked tab, step or item carries the attribute data-invalid="true" (and "false" otherwise), next to data-active and data-completed. The test screen reveal-invalid of the test applications has a required field in a second tab, in a collapsed accordion item and in the second step of a wizard.

Examples​

Standard criteria with validation action​

<criteria label="PARAMETER_TEXT" id="TxtReq" variable="TxtReq" component="text" style="col-xs-6 col-sm-3 col-lg-2" validation="{required:true, maxlength:4}"/>

Check that the password is valid​

<criteria label="PARAMETER_PASSWD" id="Pas" component="text"
validation="{required: true, pattern:{setting:'passwordPattern'}, ne:{criterion:'OldPas', message:'VALIDATOR_MESSAGE_REPEAT_OLD_PASSWORD'}, minlength:{setting:'minlengthPassword'}}"
style="col2" />

Check if a date is greater or equal than another​

<criteria label="PARAMETER_FILTERED_DATE" id="FilCalReq" variable="FilCalReq" component="filtered-calendar" initial-load="query"
target-action="FilCalDat" style="col-xs-6 col-sm-3 col-lg-2" validation="{required:true,ge:{criterion:'FilCal',type:'date'}}" strict="false" />