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
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)
isString
Returns true
if the supplied value is a string, otherwise false
.
Syntax
str.isString(value)
Arguments
value
string
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
value
string
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
value
string
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
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)
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
s1
string
The first string to compare for equality
s2
string
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
value
string
The value to match
regex
string | regex
One or more regular expressions used for matching.
Example(s)
Last updated