voltmx.string Namespace
The voltmx.string namespace forms the String API and provides the following API elements.
Functions
The voltmx.string namespace provides the following functions.
voltmx.string.containsChars
This API verifies if any one of the specified set of characters is available in the given string and returns a boolean value.
Syntax
voltmx.string.containsChars (inputstring, characterArray)
Input Parameters
Parameter | Description |
---|---|
inputstring [String] - Mandatory | Specifies the input string that needs to be verified. |
characterArray [Array] - Mandatory | Specifies the set of characters that need to be searched within the input string. |
Example
In this example, voltmx.string.containsChars returns true if the input string consists the characters specified in the characterArray. For example, since the input string _“abcd | ADV”_ consists the characters specified in the character array, voltmx.string.containsChars returns true. |
Return Values
Return Value | Description |
---|---|
status [Boolean] | true - if the given input string contains any one of the characters in the specified list.false - if there is an error in the input or if the given input string does not contain any of the specified input characters. |
Exceptions
An error is thrown if input type is invalid or follows an unexpected structure.
102-Invalid input error.
Platform Availability
Available on all platforms.
voltmx.string.containsOnlyGivenChars
This API verifies if only (and only) the specified set of characters is available in the given string and returns a boolean value.
Syntax
voltmx.string.containsOnlyGivenChars (inputstring, characterArray)
Input Parameters
Parameter | Description |
---|---|
inputstring [String] - Mandatory | Specifies the input string that needs to be verified. |
characterArray [Array] - Mandatory | Specifies the set of characters that need to be searched within the input string. |
Example
In this example, voltmx.string.containsOnlyGivenChars returns true only if the input string consists the characters specified in the characterArray. For example, since the input string “abdcdADV” consists only the characters specified in the character array, voltmx.string.containsOnlyGivenChars returns true.
Return Values
Return value | Description |
---|---|
status [Boolean] | true - if the given input string contains only the characters in the specified list.false - if there is an error in the input or if the given input string contains any other characters apart from the specified input characters. |
Exceptions
An error is thrown if input type is invalid or follows an unexpected structure.
102-Invalid input error.
Platform Availability
Available on all platforms.
voltmx.string.containsNoGivenChars
This API verifies that the input string does not contain any of the specified characters and returns a boolean value.
Syntax
voltmx.string.containsNoGivenChars (inputstring, charsArray)
Input Parameters
Parameter | Description |
---|---|
inputstring [String] - Mandatory | Specifies the input string that needs to be verified. |
charsArray [Array] - Mandatory | Specifies the set of characters that need to be searched within the input string. |
Example
In this example, voltmx.string.containsNoGivenChars returns true only if the input string does not consist the characters specified in the characterArray. For example, since the input string “abdcdADV” consists none of the characters specified in the character array, voltmx.string.containsNoGivenChars returns true.
Return Values
Return Value | Description |
---|---|
status [Boolean] | true - if the given input string contains none of the characters in the specified list.false - if there is an error in the input or if the given input string contains any of the specified input characters. |
Exceptions
An error is thrown if input type is invalid or follows an unexpected structure.
102-Invalid input error.
Platform Availability
Available on all platforms.
voltmx.string.endsWith
This API returns a boolean value indicating if the source string ends with the specified string.
Syntax
voltmx.string.endsWith(sourcestring, comparestring, ignorecase)
Input Parameters
Parameter | Description |
---|---|
sourcestring [String] - Mandatory | Specifies the source string. |
comparestring [String] - Mandatory | Specifies the string to be compared with the source string. |
ignorecase [Boolean] - Optional | Default value is true, i.e, the comparison is not case sensitive.If you want the comparison to be case sensitive, you must specify the value as false. |
Example
Return Values
Return Value | Description |
---|---|
boolean | true - source string ends with compared string.false - source string does not end with compared string. |
Platform Availability
Available on all platforms.
voltmx.string.equalsIgnoreCase
Determines whether two strings contain the same data, ignoring the case of the letters in the String.
Syntax
voltmx.string.equalsIgnoreCase(string1, string2)
Input Parameters
Parameter | Description |
---|---|
string1 [String] - Mandatory | Specifies the content of the first string. |
string2 [String] - Mandatory | Specifies the content of the second string. |
Example
Perform a voltmx.string.equalsIgnoreCase on the string “Hello” with another string “HEllo”:
The voltmx.string.equalsIgnoreCase compares the strings “Hello” and “HEllo” without case sensitivity and returns a Boolean indicating if the strings are a match.
In this example, true is the value returned.
Return Values
Return Value | Description |
---|---|
boolean | true - both strings contain exactly the same data.false - both strings do not contain exactly the same data |
Platform Availability
Available on all platforms.
voltmx.string.isAsciiAlpha
This API verifies if the input string contains only ASCII alphabet characters and returns a boolean value.
Syntax
voltmx.string.isAsciiAlpha (inputstring)
Input Parameters
Parameter | Description |
---|---|
inputstring [String] - Mandatory | Specifies the input string that needs to be verified. |
Example
In this example, the voltmx.string.isAsciiAlpha API returns true or false based on the input string entered.
Return Values
Return Value | Description |
---|---|
status [Boolean] | true - if the input string contains only alphabetic characters.false - if there is an error in the input or the input string contains characters other than alphabet. |
Exceptions
An error is thrown if input type is invalid or follows an unexpected structure.
102-Invalid input error.
Platform Availability
Available on all platforms.
voltmx.string.isAsciiAlphaNumeric
This API verifies if the input string contains only ASCII alphabet characters and numbers, and returns a boolean value.
Syntax
voltmx.string.isAsciiAlphaNumeric (inputstring)
Input Parameters
Parameter | Description |
---|---|
inputstring [String] - Mandatory | Specifies the input string that needs to be verified. |
Example
In this example, voltmx.string.isAsciiAlphaNumeric returns true or false based on the input string.
Return Values
Return Value | Description |
---|---|
status [Boolean] | true - if the input string contains only alphanumeric characters. i.e it can contain a string of numbers, characters or a string containing both numbers and characters.false - if there is an error in the input or the input string contains characters other than alphanumeric. |
Exceptions
An error is thrown if input type is invalid or follows an unexpected structure.
102-Invalid input error.
Platform Availability
Available on all platforms.
voltmx.string.isNumeric
This API verifies if the input string contains only numeric characters, and returns a boolean value.
Syntax
voltmx.string.isNumeric (inputstring)
Input Parameters
Parameter | Description |
---|---|
inputstring [String] - Mandatory | Specifies the input string that needs to be verified. |
Example
In this example, voltmx.string.isNumeric returns true if the input string has only numbers.
Return Values
Return Value | Description |
---|---|
status [Boolean] | true - if the input string contains only numeric characters.false - if there is an error in the input or the input string contains characters other than numbers. |
Exceptions
An error is thrown if input type is invalid or follows an unexpected structure.
102-Invalid input error.
Platform Availability
Available on all platforms.
voltmx.string.isValidEmail
This API verifies if the input string is a valid email address and returns a boolean value.
Syntax
voltmx.string.isValidEmail (inputstring)
Input Parameters
Parameter | Description |
---|---|
inputstring [String] - Mandatory | Specifies the input string that needs to be verified if it is a valid email address. |
Example
In this example, voltmx.string.isValidEmail returns true only if the input string comprises a valid email address.
Return Values
Return Value | Description |
---|---|
status [Boolean] | true - if the given input string satisfies the email rules and is a valid email address.false - if there is an error in the input or if the given input string does not satisfy email rules. |
Rules and Restrictions
The API performs the following validations on the input string:
- has at least 6 characters.
- has @.
- has at least 4 characters after @.
- has . (dot) followed by at least 2 characters.
- has at least 1 character before @.
Exceptions
An error is thrown if input type is invalid or follows an unexpected structure.
Platform Availability
Available on all platforms.
voltmx.string.rep
This API generates a string which is equivalent to “n copies of the source string concatenated together”.
Syntax
voltmx.string.rep(sourcestring,no)
Input Parameters
Parameter | Description |
---|---|
sourcestring [String] - Mandatory | Specifies the source string. |
no [Number] - Mandatory | Specifies the number of times the source string must be repeated. |
Example
Perform a voltmx.string.rep operation on the source string “voltmx”:
The resultant string contains voltmxvoltmxvoltmxvoltmxvoltmx.
Return Values
Return Value | Description |
---|---|
concatenatedstring [String] | A string containing n copies of the source string concatenated together is returned. |
Exceptions
An error is thrown if input type is invalid or does not follow the expected structure.
102-Invalid input error.
Platform Availability
Available on all platforms.
voltmx.string.reverse
This API reverses the characters in the source string.
Syntax
voltmx.string.reverse(string)
Input Parameters
Parameter | Description |
---|---|
string [String] - Mandatory | Specifies the source string. |
Example
Perform a reverse operation on the source string “voltmx”:
The resultant string will contain ynok.
Return Values
Return Value | Description |
---|---|
reversedstring [String] | A string containing the characters of the source string in reverse is returned. |
Exceptions
An error is thrown if input type is invalid or does not follow the expected structure.
102-Invalid input error
Platform Availability
Available on all platforms.
voltmx.string.startsWith
This API returns a boolean value indicating if the source string begins with the specified string.
Syntax
voltmx.string.startsWith(sourcestring, comparestring, ignorecase)
Input Parameters
Parameter | Description |
---|---|
sourcestring [String] - Mandatory | Specifies the source string. |
comparestring [String] - Mandatory | Specifies the string to be compared with the source string. |
ignorecase [Boolean] - Optional | Default value is true. If you do not specify the ignorecase parameter, the comparison of the string will be case insensitive. If you want the comparison to be case sensitive, you must specify the value as false. |
Example
Perform a voltmx.string.startsWith on the source string “VoltMX Solutions” for the string “voltmx” specifying the ignorecase parameter:
The voltmx.string.startsWith compares the source string “VoltMX Solutions” with the string “voltmx” without case sensitivity and returns a boolean indicating if the source string begins with the specified string.
In this example, true is the value returned.
Return Values
Return Value | Description |
---|---|
boolean | true - source string begins with the compared string.false - source string does not begin with the compared string. |
Exceptions
An error is thrown if input type is invalid or does not follow the expected structure.
102-Invalid input error.
Platform Availability
Available on all platforms.
voltmx.string.trim
This API removes the leading and ending spaces from the source string.
Syntax
voltmx.string.trim(string)
Input Parameters
Parameter | Description |
---|---|
string [String] - Mandatory | Specifies the source string. |
Example
Remove the leading and ending spaces in “ voltmx solutions “:
In this example, voltmx solutions is the value returned.
Return Values
Return Value | Description |
---|---|
trimmedstring [String] | A string without the leading and ending spaces is returned. |
Exceptions
An error is thrown if input type is invalid or does not follow the expected structure.
102-Invalid input error
Platform Availability
Available on all platforms.