str
str reference and configuration shared across Fortified ID products.
The str extension contains string helper function for validation and comparison.
Returns the size/length of a string. If the supplied value isn't a string, -1 is returned.
Syntax
Section titled “Syntax”str.size(value)
Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
value | string | The string whose length is calculated and returned. If empty, 0 is returned. If null, undefined or not a string, -1 is returned. |
Example(s)
Section titled “Example(s)”// Check if value is a string and larger than 3 charactersstr.size(scope.value) > 3isString
Section titled “isString”Returns true if the supplied value is a string, otherwise false.
Syntax
Section titled “Syntax”str.isString(value)
Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
value | string | The value to check |
Example(s)
Section titled “Example(s)”str.isString('this is a string') // truestr.isString(99) // false (number)isNullOrEmpty
Section titled “isNullOrEmpty”Returns true if the supplied value is null/undefined or an empty string ("").
Syntax
Section titled “Syntax”str.isNullOrEmpty(value)
Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
value | string | The value to check |
Example(s)
Section titled “Example(s)”str.isNullOrEmpty(null) // truestr.isNullOrEmpty("") // truestr.isNullOrEmpty('this is a string') // falseisNotNullOrEmpty
Section titled “isNotNullOrEmpty”Returns true if the supplied value is a string and is not null/undefined or empty ("").
Syntax
Section titled “Syntax”str.isNotNullOrEmpty(value)
Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
value | string | The value to check |
Example(s)
Section titled “Example(s)”str.isNotNullOrEmpty(null) // falsestr.isNotNullOrEmpty("") // falsestr.isNotNullOrEmpty('this is a string') // trueisEqual
Section titled “isEqual”Returns true if the supplied values are strings with identical content, possible with different case.
Syntax
Section titled “Syntax”str.isEqual(s1, s2[, ignoreCase])
Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
s1 | string | The first string to compare for equality |
s2 | string | The second string to compare for equality |
ignoreCase | boolean | Flag turning on case-insensitive compare (default: false) |
Example(s)
Section titled “Example(s)”str.isEqual('string value', 'string value') // truestr.isEqual('string value', 'other string value') // falsestr.isEqual('string value', 'STRING VALUE') // falsestr.isEqual('string value', 'STRING VALUE', true) // trueisEqualIgnoreCase
Section titled “isEqualIgnoreCase”Returns true if the supplied values are strings with identical content, always ignoring different case.
This function is equivalent to str.isEqual(s1, s2, true)
Syntax
Section titled “Syntax”str.isEqualIgnoreCase(s1, s2)
Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
s1 | string | The first string to compare for equality |
s2 | string | The second string to compare for equality |
Example(s)
Section titled “Example(s)”str.isEqualIgnoreCase('string value', 'string value') // truestr.isEqualIgnoreCase('string value', 'other string value') // falsestr.isEqualIgnoreCase('string value', 'STRING VALUE') // truematchAny
Section titled “matchAny”Returns true if the supplied value match any of the supplied regular expressions (regex).
Syntax
Section titled “Syntax”str.matchAny(value, regex[,regex, ...])
Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
| value | string | The value to match |
| regex | string | regex | One or more regular expressions used for matching. |
Example(s)
Section titled “Example(s)”// plain string regexstr.matchAny('value', 'v.*') // true
// typed regex (format: /regex/flags)str.matchAny('value', /v.*/) // truestr.matchAny('value', /[0-9]{1,3}/) // false
// case insensitive match using i-flagstr.matchAny('value', /V.*/i) // true