Conditional execution
Overview
Section titled “Overview”Conditional execution determine whether different components should execute or not.
Fortified ID's products use Javascript for this. There are four different parts of the products that use this. This document contains various examples for common tasks. How to address data that you might want to use is described in one of the four sub-documents and depends on what you are going to do.
Common syntax examples
Section titled “Common syntax examples”When validating data with JavaScript, the goal is to ensure that the information entered by a user or provided to your application meets certain rules before it’s processed.
We work with scopes and properties.
In our products an scopes can be Session, Exports, Item or Request. Values that describes are stored in properties.
To address scopes and properties you write for example session.date_of_birth, exports.groups, item.dn.
All scopes are not available in all places, therefore we have created sub pages that show examples how and where they apply.
Required fields
Section titled “Required fields”- Username is NOT required
(!object.username) - Vad gör nedan?
param1 == 'value1' - Vad gör nedan?
param1 !== 'value2' - Vad gör nedan?
param1 != 'value2'
Data type checks
Section titled “Data type checks”- Age must a number, Not a Number (NaN)
!isNaN(exports.age) - Next
Length checks
Section titled “Length checks”- Password must be at least 8 characters long
password.length > 8 - Next
Pattern checks with Regular Expressions (Regex)
Section titled “Pattern checks with Regular Expressions (Regex)”Useful for formats like email or phone numbers.
- Invalid email address
emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
(!emailPattern.test(email)) - Next
Range checks
Section titled “Range checks”- Age must be between 18 and 100
age < 18 || age > 100 - Next
In this section