Script extension for multi value validation and comparison.
All functions operating on multi values will convert supplied value(s) to multi value if not already (see mv.from(value))
In JavaScript multi values are represented as arrays.
Converts a value to a multi value if not already.
Handles the following types of input values:
json arrays (parsed to array)
single values of any types (added as first element to new array)
mv.from(value)
The value to convert to multi value
Returns the length of the supplied multi value.
mv.length(value)
The multi value whose length is to be calculated and returned.
Returns true if the supplied multi value contains the supplied expected value, possibly ignoring the case (if values are strings).
Note: This function works exactly like mv.containsAny but with support for only one expected value.
mv.contains(value, expected[, ignoreCase])
The multi value whose content is to be asserted.
Value expected to be contained in value
Flag turning on string case insensitivity (default: false)
Returns true if the supplied multi value contains at least one of the supplied expected values, possibly ignoring the case (if values are strings).
mv.containsAny(value, expected[, expected, ...][, ignoreCase])
The multi value whose content is to be asserted.
One or more values expected to be contained in value
Flag turning on string case insensitivity (default: false)
Returns true if the supplied multi value contains all of the supplied expected values, possibly ignoring the case (if values are strings).
mv.containsAll(value, expected[, expected, ...][, ignoreCase])
The multi value whose content is to be asserted.
One or more values expected to be contained in value
Flag turning on string case insensitivity (default: false)
Returns true if at least one value in the supplied multi value matches one or more of the supplied regex's.
Regex may be supplied as strings, regex-literals or RegExp objects.
Note: Case-insensitivity is controlled by regex flag ('i').
mv.matchAny(value, regex [,regex, ...])
The multi value whose content is to be matched.
One or more regex to match against value.
Returns true if the supplied multi values has exactly same content.
mv.equals(mv1, mv2)
The multi value whose content is to be matched.
One or more regex to match against value.
Returns true if the supplied multi value is not null/undefined and is empty.
mv.isEmpty(value)
The multi value to assert
Returns true if the supplied multi value is not null/undefined and is not empty (has one or more elements).
mv.isNotEmpty(value)
The multi value to assert
mv.isNullOrEmpty
Returns true if the supplied multi value is null/undefined or is empty.
mv.isNullOrEmpty(value)
The multi value to assert
mv.isNotNullOrEmpty
Returns true if the supplied multi value is not null/undefined and is not empty (has one or more element).
mv.isNotNullOrEmpty(value)
The multi value to assert