Skip to content

Fortified IDDocs

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.

str.size(value)

NameTypeDescription
valuestringThe string whose length is calculated and returned. If empty, 0 is returned. If null, undefined or not a string, -1 is returned.
// Check if value is a string and larger than 3 characters
str.size(scope.value) > 3

Returns true if the supplied value is a string, otherwise false.

str.isString(value)

NameTypeDescription
valuestringThe value to check
str.isString('this is a string') // true
str.isString(99) // false (number)

Returns true if the supplied value is null/undefined or an empty string ("").

str.isNullOrEmpty(value)

NameTypeDescription
valuestringThe value to check
str.isNullOrEmpty(null) // true
str.isNullOrEmpty("") // true
str.isNullOrEmpty('this is a string') // false

Returns true if the supplied value is a string and is not null/undefined or empty ("").

str.isNotNullOrEmpty(value)

NameTypeDescription
valuestringThe value to check
str.isNotNullOrEmpty(null) // false
str.isNotNullOrEmpty("") // false
str.isNotNullOrEmpty('this is a string') // true

Returns true if the supplied values are strings with identical content, possible with different case.

str.isEqual(s1, s2[, ignoreCase])

NameTypeDescription
s1stringThe first string to compare for equality
s2stringThe second string to compare for equality
ignoreCasebooleanFlag turning on case-insensitive compare (default: false)
str.isEqual('string value', 'string value') // true
str.isEqual('string value', 'other string value') // false
str.isEqual('string value', 'STRING VALUE') // false
str.isEqual('string value', 'STRING VALUE', true) // true

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)

str.isEqualIgnoreCase(s1, s2)

NameTypeDescription
s1stringThe first string to compare for equality
s2stringThe second string to compare for equality
str.isEqualIgnoreCase('string value', 'string value') // true
str.isEqualIgnoreCase('string value', 'other string value') // false
str.isEqualIgnoreCase('string value', 'STRING VALUE') // true

Returns true if the supplied value match any of the supplied regular expressions (regex).

str.matchAny(value, regex[,regex, ...])

NameTypeDescription
valuestringThe value to match
regexstring | regexOne or more regular expressions used for matching.
// plain string regex
str.matchAny('value', 'v.*') // true
// typed regex (format: /regex/flags)
str.matchAny('value', /v.*/) // true
str.matchAny('value', /[0-9]{1,3}/) // false
// case insensitive match using i-flag
str.matchAny('value', /V.*/i) // true