str
The str extension contains string helper function for validation and comparison.
size
Returns the size/length of a string. If the supplied value isn't a string, -1 is returned.
Syntax
str.size(value)
Arguments
Name | Type | Description |
---|---|---|
|
| The string whose length is calculated and returned. If empty, |
Example(s)
isString
Returns true
if the supplied value is a string, otherwise false
.
Syntax
str.isString(value)
Arguments
Name | Type | Description |
---|---|---|
|
| The value to check |
Example(s)
isNullOrEmpty
Returns true
if the supplied value is null
/undefined
or an empty string (""
).
Syntax
str.isNullOrEmpty(value)
Arguments
Name | Type | Description |
---|---|---|
|
| The value to check |
Example(s)
isNotNullOrEmpty
Returns true
if the supplied value is a string and is not null
/undefined
or empty (""
).
Syntax
str.isNotNullOrEmpty(value)
Arguments
Name | Type | Description |
---|---|---|
|
| The value to check |
Example(s)
isEqual
Returns true
if the supplied values are strings with identical content, possible with different case.
Syntax
str.isEqual(s1, s2[, ignoreCase])
Arguments
Name | Type | Description |
---|---|---|
|
| The first string to compare for equality |
|
| The second string to compare for equality |
|
| Flag turning on case-insensitive compare (default: |
Example(s)
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
str.isEqualIgnoreCase(s1, s2)
Arguments
Name | Type | Description |
---|---|---|
|
| The first string to compare for equality |
|
| The second string to compare for equality |
Example(s)
matchAny
Returns true
if the supplied value match any of the supplied regular expressions (regex).
Syntax
str.matchAny(value, regex[,regex, ...])
Arguments
Name | Type | Description |
---|---|---|
value |
| The value to match |
regex |
| One or more regular expressions used for matching. |
Example(s)
Last updated