-
Notifications
You must be signed in to change notification settings - Fork 8
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'.
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.
The standard comparison operators can be used: ==, !=, <, <=, >, >=.
value > 10value == 'Endo'-
value >= 'Toto'(strings are compared alphabetically)
The 'and' && and 'or' || are available.
value == 'Riri' || value == 'Fifi' || value == 'Loulou'value > 10 && value <= 20
Also, the 'not' ! operator is available and can invert an expression.
-
!valuewhen value is a boolean. It's the same asvalue == false !(value > 10)
Predicates can use advanced operators.
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".
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".
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".
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".
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".
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.