Predicates
Predicates are used to filter the value with some commands like the path listing command.
The variable 'value' in the predicate will be replaced when evaluating a value against the predicate.
For instance, the predicate value > 10
will validate only the numeric values that are greater than 10.
Strings have to be specified with single quotes to distinguish them from a variable: value == 'String'
.
It's possible to use logic operators in a predicate to specify advanced conditions. For instance, value > 10 && value <= 20
.
A predicate cannot use the 'value' variable with different types. For instance, value > 10 && value hasPrefix 'to'
is not a valid predicate, as 'value' could be numeric or a string.
Standard operators
The standard comparison operators can be used: ==
, !=
, <
, <=
, >
, >=
value > 10
value == 'Endo'
value >= 'Toto'
(strings are compared alphabetically)
Logic operators
The 'and' &&
and 'or' ||
are available.
value == 'Riri' || value == 'Fifi' || value == 'Loulou'
value > 10 && value <= 20
!
operator is available and can invert an epxression.
!value
when value is a boolean. It's the same asvalue == false
!(value > 10)
Advanced operators
Predicates can use advanced operators.contains
Works with strings.
true when the left operand contains the right operand. Case sensitive.
Ex: value contains 'ulou'
. true when value: "Loulou", false when value: "Riri".
isIn
Works with strings.
true when the left operand matches a value given in the right operand.
The right operand is a list of string separated with commas. Use backslach to escape a comma in a string.
Ex: value isIn 'Riri, Fifi, Loulou'
. true when value: "Riri". false when value: "Donald".
hasPrefix
Works with strings.
true when the left operand starts with the right operand. Case sensitive.
Ex: value hasPrefix 'Ri'
. true when value: "Riri". false when value: "Fifi".
hasSuffix
Works with strings.
true when the left operand ends with the right operand. Case sensitive.
Ex: value hasSuffix 'lou'
. true when value: "Loulou". false when value: "Fifi".
matches
Works with strings.
true when the left operand matches the regular expression given as the right operand.
The whole left operand has to match the regular expression to be validated.
Ex: value matches '[0-9]{3}'
. true when value: "123". false when value: "1010".
Boolean
When the value is a boolean, it's possible to only specify it.
Ex: value
. true if value is: true. It's the same as value == true
.
It's possible to use the 'not' !
operator to invert a boolean or an expression.
Ex: !value
. true when value is: false. It's the same as value == false
.