Writing conditions
Introduction
Several special grammatical structures within ClauseBase allow you to write conditions.
For example, in the following conditional text, the condition #applicablelaw^name expresses the objective that the text that follows after the colon should only be shown if the datafield name of concept #applicablelaw is equal to the word “belgian”.
{ #applicablelaw^= "belgian" : ... }
General structure
In their most basic appearance, conditions follow the structure:
left value comparison operator right value
The left value and right value can be any of the following value types:
value type  explanation  examples 
number  whole number, or floatingpoint number (with decimal part)  5 1234 123.5 
text  either between single quotes (‘) or double quotes (“)  ‘Brussels’ “Paris” 
date  should be expressed as year_month_day  2000_12_23 (23 Dec 2000) 2016_1_5 (5 Jan 2016) 
currency  a (potentially fractional) number and one of the supported currencies (EUR, USD, JPY or GBP)  5 EUR 6.78 JPY 
duration  a number and a time unit (week, year, day, quarter, or year)  5 weeks 3 months 4 years 
true/false  the truth value true or false  true false 
list  a uniform or mixed list of elements  @list(5, 6, 7) @list(‘Brussels, ‘Amsterdam’) @list(5, ‘Brussels’, 6 days) 
The comparison operator can be any of the following:
OPERATOR  DESCRIPTION  EXAMPLE 
=  equal to  #applicablelaw^name = ‘belgian’ 
!=  not equal to  #parties^amount != 2 
<  smaller than  #contract^value < 2000 EUR 
>  larger than  #contract^value > 2000 EUR 
<=  smaller than, or equal to  #contract^value <= 2000 EUR 
>=  larger than, or equal to  #contract^value >= 2000 EUR 
in  present in the list  #competentcourt^name in @list(‘Brussels’, ‘Amsterdam’) 
!in  not present in the list  #product^type !in @list(‘typeA’, ‘typeB’, ‘typeB’) 
Datafields
When building conditions for clauses, you can either use static values (e.g., “5 weeks” or “234.5 EUR”), or use dynamic values by referring to datafields through the syntax #concept^datafield (e.g., #applicablelaw^name).
Unlike a static value, the actual value of a datafield is not known by the clause author, and will instead be determined by the clause user — e.g., by submitting a value in the data dashboard, or by selecting a value in a Q&A session. At the moment ClauseBase is about to show a clause, it will look up the current value, and use it in subsequent calculations.
Datafields will always take on one of the value types above (number, text, currency, duration, etc.). This value type needs to be selected upfront when constructing a Concept.
When the user has not yet assigned a value to a datafield, the value of that datafield is said to be undefined. When drafting clauses, you should take into account the possibility of such undefined values.
Mathematical operations
Numerical values can be combined in larger structures through the basic mathematical operations (+, , / and *). Examples:
#contract^value < 5000 EUR + 2400 EUR
#contract^value < 5000 EUR  #liability^cap
(#contract^value * 1.2) < 5000 EUR
Note that parentheses can be used to clarify which parts of the formula should be taken first. If no parentheses are used, then the wellknown mathematical rules of precedence are used — i.e., multiplication and division take precedence over addition and subtraction, so that 1 + 2 * 3 is equal to 7 (not 9).
For example, 100/3 will result in 33, while 100.0/3 and 100/3.0 and 100.0/3.0 will all result in 33.33.
Details
Shorthand comparisons
If the operator and right value of a comparison are omitted, then the comparison will result in true if the left value:
 is equal to true
 is equal to a nonempty text value
 is equal to a number or currency that is different from zero
 is equal to a duration higher than zero
 is equal to a nonempty list
In other words, the comparison will be false if the left value:
 is undefined
 is equal to false
 is equal to empty text (“”)
 is equal to a number or currency that is equal to zero
 is an empty list
This allows you to for example write the following shorthand conditions:
{ #contract^value: ... }
{ #contract^duration: ... }
{ #employee^name: ... }
In all of these examples, the … will only be shown if the preceding datafield is assigned a decent value. If in the first example the contract value would not have been assigned, or be equal to zero, then the … will not be shown. Similarly, if the duration would not have been assigned, or be equal to zero, or if the employee’s name would not have been assigned, or be set to an empty text, then the … will not be shown in the second and third example.
Supported mathematical conversions
To a limited extent, values of different types can be combined with each other in comparisons or mathematical operations. The following rules apply:
VALUE TYPE 1  VALUE TYPE 2  RESULT  DESCRIPTION OR EXAMPLE 
number  currency  currency  3000 EUR + 200 results in 3200 EUR 
duration  duration  duration, with the time unit converted to the most relevant one 

date  duration  date 

For example, 1 year + 1 month + 1 day will be evaluated in two steps, ultimately resulting in 404 days.
 first 1 year + 1 month (= converted to 13 months)
 then 13 months + 1 day (= (13 * 31) + 1 = 404 days)
Note the difference with 1 year + (1 month + 1 day), which would be evaluated as 1 year + 32 days = 397 days. A discrepancy of 7 days!
Disallowed mathematical operations
The following mathematical operations will lead to errors in ClauseBase.
 dividing a number by zero
 mixing different currencies (e.g., 300 EUR + 500 USD)
 adding or subtracting dates (e.g., 2018_7_15 + 2018_1_1)
 mixing a date/duration and a number (e.g., 2018_7_15 + 14, or 5 weeks + 6)
 mixing texts with other types (e.g., 5 July 2018 + ‘Brussels’, or 500 EUR + ‘2 cents’)
For example, if you would have two dates available and would like to check whether the duration between them is beyond a certain threshold, you could write #concept^date1 + 3 months < #concept^date2.
Conversion of undefined values
ClauseBase will automatically convert undefined values to values that make sense in comparisons or mathematical operations:
OTHER TYPE  UNDEFINED WILL BE CONVERTED INTO  EXAMPLE 
number  0  5 + undefined results in 55 * undefined results in 0 
currency  0 (same valuta)  5 EUR + undefined results in 5 EUR5 EUR * undefined results in 0 EUR 
duration  duration with length 0  5 days + undefined results in 5 days 
text  empty text  ” = undefined is true 
list  empty list  @emptylist() = undefined is true 
Combining subconditions: AND/OR/NOT
Different subconditions can be combined through AND, OR and NOT.
For example, the following combination of subconditions will only apply if Dutch law applies, and the competent court is simultaneously set to Amsterdam:
#applicablelaw^name = 'belgian' AND #competentcourt^location = 'Amsterdam'
For example, the sentence “Marie will go to the city when it is Tuesday and when John calls” will usually be understood as “Marie will go on Tuesday, but will also go on other days when John calls”. Hence, in everyday language, the word “and” can sometimes express that something applies when any of the subparts apply. Whether this is indeed the case — or whether “and” should instead be interpreted as “only apply when both subparts apply at the same time” — can usually be inferred from the context.
In most situations, this linguistical ambiguity is not a problem, because the context will be clear or because the consequences of the wrong interpretation are negligible. However, such ambiguities are sometimes also found in contracts and laws, and then the context may not always be clear, and/or the consequences may be significant
When building conditions in ClauseBase, such ambiguities will not arise, because the word “AND” means “both subconditions must apply”, and is thereby clearly opposed to the word “OR”, which means “it is sufficient if any of the subconditions applies”.
Much more complex combinations of subconditions are possible. The following combination will only apply if either of the following two bullets applies:
 Dutch law applies and the competent court is simultaneously set to Amsterdam; or
 the contract value is higher than 5.000 EUR
(#applicablelaw^name = 'belgian' AND #competentcourt^location = 'Amsterdam') OR (#contract^value > 5000 EUR)
Please note that the way parentheses are used, is very important. The following example is identical to the previous one, with the exception of the parentheses:
#applicablelaw^name = 'belgian' AND (#competentcourt^location = 'Amsterdam' OR #contract^value > 5000 EUR)
The change in parentheses causes a significant change in meaning, because the subconditions between parentheses will be evaluated first, before evaluating the other subconditions. The combination of subconditions will now only apply if both of the following subconditions simultaneously apply:
 the applicable law is Belgian
 the competent court is Amsterdam AND, in addition, the contract value is higher than 5000 EUR
#applicablelaw^name = ‘belgian’ AND #competentcourt^location = ‘Brussels’ AND #contract^value > 5000 EUR
Similarly, it is also fine to create a chain of OR conditions without any parentheses.
What is problematic, however, is to chain AND and OR conditions without parentheses. For example:
#applicablelaw^name = ‘belgian’ AND #competentcourt^location = ‘Brussels’ OR #contract^value > 5000 EUR
Should this be understood as: “apply in any of the following situations: (1) Belgian law applies and simultaneously the competent court is Brussels; (2) the contract value is higher than 5000 EUR”, or should it instead be understood as “only apply when both of the following situations apply: (1) Belgian law applies; (2) either the court of Brussels is competent, or the contract value is 5000 EUR”?
There are rules of precedence that dictate how the software will evaluate this combination of subconditions. However, these rules are rather counterintuitive, so that it is always better to uses parentheses with any mix of AND and OR.
NOT subconditions should always be surrounded by parentheses. Example:
NOT (#applicablelaw^name = 'belgian' AND
#competentcourt^location = 'Brussels' AND #contract^value > 5000 EUR)
This combination of subconditions will apply when the following combination of situations does not simultaneously apply:
 Belgian law applies
 the competent court is Brussels
 the contract value is higher than 5000 EUR
In other words, this combination of subconditions will apply when Belgian law would not apply, or when the competent could would not be Brussels, or when the contract value would be lower than (or equal to) 5000 EUR.
NOT(A OR B) is equal to ((NOT A) AND (NOT B))
NOT(A AND B) is equal to ((NOT A) OR (NOT B))
The previous example with a chain of ANDs can therefore also be converted to a chain of OR, with the operators (= and >) reversed:
#applicablelaw^name != ‘belgian’ OR #competentcourt^location != ‘Brussels’ OR #contract^value <= 5000 EUR