Variable property test primitives.
More...
Variable property test primitives.
See validation results group1 and group2.
function all_defined |
( |
v |
| ) |
|
Test if no element of a value is undefined.
- Parameters
-
v | <value> A value or an iterable value. |
- Returns
- <boolean> true when no element is undefined and false otherwise.
- Warning
- Always returns true when
v
is empty.
function all_equal |
( |
v |
, |
|
|
cv |
|
|
) |
| |
Test if all elements of a value equal a comparison value.
- Parameters
-
v | <value> A value or an iterable value. |
cv | <value> A comparison value. |
- Returns
- <boolean> true when all elements equal the value
cv
and false otherwise.
- Warning
- Always returns true when
v
is empty.
function all_len |
( |
v |
, |
|
|
l |
|
|
) |
| |
Test if all elements of a value have a given length.
- Parameters
-
v | <value> A value or an iterable value. |
l | <integer> The length. |
- Returns
- <boolean> true when all elements have length equal to
l
and false otherwise. Returns the value of v
when it is not defined.
- Warning
- Always returns true when
v
is empty.
function all_numbers |
( |
v |
| ) |
|
Test if all elements of a value are numbers.
- Parameters
-
v | <value> A value or an iterable value. |
- Returns
- <boolean> true when all elements are numerical values and false otherwise. Returns true when
v
is a single numerical value. Returns the value of v
when it is not defined.
- Warning
- Always returns true when
v
is empty.
function all_scalars |
( |
v |
| ) |
|
Test if all elements of a value are scalars.
- Parameters
-
v | <value> A value or an iterable value. |
- Returns
- <boolean> true when all elements are scalar values and false otherwise. Returns true when
v
is a single scalar value. Returns the value of v
when it is not defined.
- Warning
- Always returns true when
v
is empty.
function all_strings |
( |
v |
| ) |
|
Test if all elements of a value are strings.
- Parameters
-
v | <value> A value or an iterable value. |
- Returns
- <boolean> true when all elements are string values and false otherwise. Returns true when
v
is a single string value. Returns the value of v
when it is not defined.
- Warning
- Always returns true when
v
is empty.
function all_vectors |
( |
v |
| ) |
|
Test if all elements of a value are vectors.
- Parameters
-
v | <value> A value or an iterable value. |
- Returns
- <boolean> true when all elements are vector values and false otherwise. Returns true when
v
is a single vector value. Returns the value of v
when it is not defined.
- Warning
- Always returns true when
v
is empty.
function almost_equal |
( |
v1 |
, |
|
|
v2 |
, |
|
|
p |
= 4 |
|
) |
| |
Test if all elements of two values are approximately equal.
- Parameters
-
v1 | <value> A value or an iterable value 1. |
v2 | <value> A value or an iterable value 2. |
p | <number> A numerical precision. |
- Returns
- <boolean> true when all elements of each values are sufficiently equal and false otherwise. All numerical comparisons are performed with precision limited by
p
. All non-numeric comparisons test for exact equality.
- Note
- The parameter
p
indicated the number of digits of precision for each numerical comparison.
- Warning
- Always returns true when
v
is empty.
function any_equal |
( |
v |
, |
|
|
cv |
|
|
) |
| |
Test if any element of a value equals a comparison value.
- Parameters
-
v | <value> A value or an iterable value. |
cv | <value> A comparison value. |
- Returns
- <boolean> true when any element equals the value
cv
and false otherwise.
- Warning
- Always returns false when
v
is empty.
function any_undefined |
( |
v |
| ) |
|
Test if any element of a value is undefined.
- Parameters
-
v | <value> A value or an iterable value. |
- Returns
- <boolean> true when any element is undefined and false otherwise.
- Warning
- Always returns false when
v
is empty.
function compare |
( |
v1 |
, |
|
|
v2 |
, |
|
|
s |
= true |
|
) |
| |
Compare any two values (may be iterable and/or of different types).
- Parameters
-
v1 | <value> A value or an iterable value 1. |
v2 | <value> A value or an iterable value 2. |
s | <boolean> Order ranges by their numerical sum. |
- Returns
- <integer> -1 when
(v2 < v1)
, +1 when (v2 > v1)
, and 0 when (v2 == v1)
.
The following table summarizes how values are ordered.
order | type | s | intra-type ordering |
1 | undef | | (singular) |
2 | number | | numerical comparison |
3 | string | | lexical comparison |
4 | boolean | | false < true |
5 | vector | | lengths then element-wise comparison |
6 | range | true | compare sum of range elements |
6 | range | false | lengths then element-wise comparison |
- Note
- When comparing two vectors of equal length, the comparison continue element-by-element until an ordering can be determined. Two vectors are declared equal when all elements have been compared and no ordering has been determined.
- Warning
- The performance of element-wise comparisons of vectors degrades exponentially with vector size.
-
The sum of a range may quickly exceeded the intermediate variable storage capacity for long ranges.
function is_boolean |
( |
v |
| ) |
|
Test if a value is a boolean constant.
- Parameters
-
- Returns
- <boolean> true when the value is one of the predefined boolean constants
[true|false]
and false otherwise.
function is_decimal |
( |
v |
| ) |
|
Test if a value is a decimal.
- Parameters
-
- Returns
- <boolean> true when the value is a decimal and false otherwise.
function is_defined |
( |
v |
| ) |
|
Test if a value is defined.
- Parameters
-
- Returns
- <boolean> true when the value is defined and false otherwise.
Test if an iterable value is empty.
- Parameters
-
v | <value> An iterable value. |
- Returns
- <boolean> true when the iterable value has zero elements and false otherwise.
Test if a numerical value is even.
- Parameters
-
v | <value> A numerical value. |
- Returns
- <boolean> true when the value is determined to be even and false otherwise.
- Note
- The value must be valid and defined but may be positive or negative. Any value that is not an integer returns false.
Test if a numerical value is infinite.
- Parameters
-
v | <value> A numerical value. |
- Returns
- <boolean> true when the value is determined to be inf (greater than the largest representable number) and false otherwise.
function is_integer |
( |
v |
| ) |
|
Test if a value is an integer.
- Parameters
-
- Returns
- <boolean> true when the value is an integer and false otherwise.
function is_iterable |
( |
v |
| ) |
|
Test if a value has multiple parts and is iterable.
- Parameters
-
- Returns
- <boolean> true when the value is an iterable multi-part value and false otherwise.
value is | defined result |
undef | false |
inf | false |
nan | false |
integer | false |
decimal | false |
boolean | false |
string | true |
vector | true |
range | not defined |
Test if a numerical value is invalid.
- Parameters
-
v | <value> A numerical value. |
- Returns
- <boolean> true when the value is determined to be nan (Not A Number) and false otherwise.
Test if a value is a number.
- Parameters
-
- Returns
- <boolean> true when the value is a number and false otherwise.
- Warning
- Returns true even for numerical values that are considered infinite and invalid.
Test if a numerical value is odd.
- Parameters
-
v | <value> A numerical value. |
- Returns
- <boolean> true when the value is determined to be odd and false otherwise.
- Note
- The value must be valid and defined but may be positive or negative. Any value that is not an integer returns false.
Test if a value is a range definition.
- Parameters
-
- Returns
- <boolean> true when the value is a range definition and false otherwise.
Test if a value is a single non-iterable value.
- Parameters
-
- Returns
- <boolean> true when the value is a single non-iterable value and false otherwise.
value is | defined result |
undef | true |
inf | true |
nan | true |
integer | true |
decimal | true |
boolean | true |
string | false |
vector | false |
range | not defined |
Test if a value is a string.
- Parameters
-
- Returns
- <boolean> true when the value is a string and false otherwise.
Test if a value is a vector.
- Parameters
-
- Returns
- <boolean> true when the value is a vector and false otherwise.
function not_defined |
( |
v |
| ) |
|
Test if a value is not defined.
- Parameters
-
- Returns
- <boolean> true when the value is not defined and false otherwise.