Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(feel): Clarify edge cases in FEEL expressions #4222

Merged
merged 5 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ string(date("2012-12-25"))

Parses the given string to a number.

Returns `null` if the string is not a number.

**Function signature**

```feel
Expand Down Expand Up @@ -72,6 +74,9 @@ context([{"key":"a", "value":1}, {"key":"b", "value":2}])

Returns a date from the given value.

Returns `null` if the string is not a valid calendar date. For example, `"2024-06-31"` is invalid because June has
only 30 days.

**Function signature**

```feel
Expand Down Expand Up @@ -100,6 +105,9 @@ date(date and time("2012-12-25T11:00:00"))

Returns a date from the given components.

Returns `null` if the components don't represent a valid calendar date. For example, `2024,6,31` is invalid because
June has only 30 days.

**Function signature**

```feel
Expand Down Expand Up @@ -179,6 +187,9 @@ time(14, 30, 0, duration("PT1H"))

Parses the given string into a date and time.

Returns `null` if the string is not a valid calendar date. For example, `"2024-06-31T10:00:00"` is invalid because
June has only 30 days.

**Function signature**

```feel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ The `start position` starts at the index `1`. The last position is `-1`.
```feel
substring("foobar", 3)
// "obar"

substring("foobar", -2)
// "ar"
```

## substring(string, start position, length)

Returns a substring of the given value starting at `start position`.
Returns a substring of the given value, starting at `start position` with the given `length`. If `length` is greater than
the remaining characters of the value, it returns all characters from `start position` until the end.

**Function signature**

Expand All @@ -42,6 +46,12 @@ The `start position` starts at the index `1`. The last position is `-1`.
```feel
substring("foobar", 3, 3)
// "oba"

substring("foobar", -3, 2)
// "ba"

substring("foobar", 3, 10)
// "obar"
```

## string length(string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ duration("P3M")
@"P3M"
```

The value is `null` if a date or date-time literal doesn't represent a valid calendar date. For example, `@"2024-06-31"` is invalid because June has only 30 days.

### Addition

Adds a value to another value. The operator is defined for the followings types.
Adds a value to another value. The operator is defined for the following types.

If a value has a different type, the result is `null`.

Expand Down
13 changes: 7 additions & 6 deletions docs/components/modeler/feel/language-guide/feel-unary-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ entries of a decision table (i.e. the conditions of a rule).

A unary-tests expression returns `true` if one of the following conditions is fulfilled:

- The expression evaluates to `true` when the input value is applied to it.
- The expression evaluates to a list, and the input value is equal to at least one of the values in
that list.
- The expression evaluates to `true` when the input value is applied to the unary operators.
- The expression evaluates to `true` when the input value is assigned to the special variable `?`.
- The expression evaluates to a value, and the input value is equal to that value.
- The expression evaluates to a list, and the input value is equal to at least one of the values.
- The expression is equal to `-` (a dash).

### Comparison
Expand Down Expand Up @@ -129,13 +129,14 @@ not(2, 3)

### Expressions

Evaluates an expression that returns a boolean value. For example, [invoking a function](/components/modeler/feel/language-guide/feel-functions.md#invocation).
When a unary operator is not enough to express the condition, any expression that returns a boolean value can be used,
such as [invoking a function](/components/modeler/feel/language-guide/feel-functions.md#invocation).

The input value can be accessed in the expression by using the symbol `?` (a question mark).
In the expression, the input value can be accessed by the special variable `?`.

```feel
contains(?, "good")
// check if the input value (string) contains "good"
// checks if the input value (string) contains "good"

ends with(?, "@camunda.com")
// checks if the input value (string) ends with "@camunda.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ string(date("2012-12-25"))

Parses the given string to a number.

Returns `null` if the string is not a number.

**Function signature**

```feel
Expand Down Expand Up @@ -72,6 +74,9 @@ context([{"key":"a", "value":1}, {"key":"b", "value":2}])

Returns a date from the given value.

Returns `null` if the string is not a valid calendar date. For example, `"2024-06-31"` is invalid because June has
only 30 days.

**Function signature**

```feel
Expand Down Expand Up @@ -100,6 +105,9 @@ date(date and time("2012-12-25T11:00:00"))

Returns a date from the given components.

Returns `null` if the components don't represent a valid calendar date. For example, `2024,6,31` is invalid because
June has only 30 days.

**Function signature**

```feel
Expand Down Expand Up @@ -179,6 +187,9 @@ time(14, 30, 0, duration("PT1H"))

Parses the given string into a date and time.

Returns `null` if the string is not a valid calendar date. For example, `"2024-06-31T10:00:00"` is invalid because
June has only 30 days.

**Function signature**

```feel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ The `start position` starts at the index `1`. The last position is `-1`.
```feel
substring("foobar", 3)
// "obar"

substring("foobar", -2)
// "ar"
```

## substring(string, start position, length)

Returns a substring of the given value starting at `start position`.
Returns a substring of the given value, starting at `start position` with the given `length`. If `length` is greater than
the remaining characters of the value, it returns all characters from `start position` until the end.

**Function signature**

Expand All @@ -42,6 +46,12 @@ The `start position` starts at the index `1`. The last position is `-1`.
```feel
substring("foobar", 3, 3)
// "oba"

substring("foobar", -3, 2)
// "ba"

substring("foobar", 3, 10)
// "obar"
```

## string length(string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ duration("P3M")
@"P3M"
```

The value is `null` if a date or date-time literal doesn't represent a valid calendar date. For example, `@"2024-06-31"` is invalid because June has only 30 days.

### Addition

<table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ entries of a decision table (i.e. the conditions of a rule).

A unary-tests expression returns `true` if one of the following conditions is fulfilled:

- The expression evaluates to `true` when the input value is applied to it.
- The expression evaluates to a list, and the input value is equal to at least one of the values in
that list.
- The expression evaluates to `true` when the input value is applied to the unary operators.
- The expression evaluates to `true` when the input value is assigned to the special variable `?`.
- The expression evaluates to a value, and the input value is equal to that value.
- The expression evaluates to a list, and the input value is equal to at least one of the values.
- The expression is equal to `-` (a dash).

### Comparison
Expand Down Expand Up @@ -128,13 +128,14 @@ not(2, 3)

### Expressions

Evaluates an expression that returns a boolean value. For example, [invoking a function](/docs/components/modeler/feel/language-guide/feel-functions#invocation).
When a unary operator is not enough to express the condition, any expression that returns a boolean value can be used,
such as [invoking a function](/components/modeler/feel/language-guide/feel-functions.md#invocation).

The input value can be accessed in the expression by using the symbol `?` (a question mark).
In the expression, the input value can be accessed by the special variable `?`.

```feel
contains(?, "good")
// check if the input value (string) contains "good"
// checks if the input value (string) contains "good"

ends with(?, "@camunda.com")
// checks if the input value (string) ends with "@camunda.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ string(date("2012-12-25"))

Parses the given string to a number.

Returns `null` if the string is not a number.

**Function signature**

```feel
Expand Down Expand Up @@ -72,6 +74,9 @@ context([{"key":"a", "value":1}, {"key":"b", "value":2}])

Returns a date from the given value.

Returns `null` if the string is not a valid calendar date. For example, `"2024-06-31"` is invalid because June has
only 30 days.

**Function signature**

```feel
Expand Down Expand Up @@ -100,6 +105,9 @@ date(date and time("2012-12-25T11:00:00"))

Returns a date from the given components.

Returns `null` if the components don't represent a valid calendar date. For example, `2024,6,31` is invalid because
June has only 30 days.

**Function signature**

```feel
Expand Down Expand Up @@ -179,6 +187,9 @@ time(14, 30, 0, duration("PT1H"))

Parses the given string into a date and time.

Returns `null` if the string is not a valid calendar date. For example, `"2024-06-31T10:00:00"` is invalid because
June has only 30 days.

**Function signature**

```feel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ The `start position` starts at the index `1`. The last position is `-1`.
```feel
substring("foobar", 3)
// "obar"

substring("foobar", -2)
// "ar"
```

## substring(string, start position, length)

Returns a substring of the given value starting at `start position`.
Returns a substring of the given value, starting at `start position` with the given `length`. If `length` is greater than
the remaining characters of the value, it returns all characters from `start position` until the end.

**Function signature**

Expand All @@ -42,6 +46,12 @@ The `start position` starts at the index `1`. The last position is `-1`.
```feel
substring("foobar", 3, 3)
// "oba"

substring("foobar", -3, 2)
// "ba"

substring("foobar", 3, 10)
// "obar"
```

## string length(string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ duration("P3M")
@"P3M"
```

The value is `null` if a date or date-time literal doesn't represent a valid calendar date. For example, `@"2024-06-31"` is invalid because June has only 30 days.

### Addition

Adds a value to another value. The operator is defined for the followings types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ entries of a decision table (i.e. the conditions of a rule).

A unary-tests expression returns `true` if one of the following conditions is fulfilled:

- The expression evaluates to `true` when the input value is applied to it.
- The expression evaluates to a list, and the input value is equal to at least one of the values in
that list.
- The expression evaluates to `true` when the input value is applied to the unary operators.
- The expression evaluates to `true` when the input value is assigned to the special variable `?`.
- The expression evaluates to a value, and the input value is equal to that value.
- The expression evaluates to a list, and the input value is equal to at least one of the values.
- The expression is equal to `-` (a dash).

### Comparison
Expand Down Expand Up @@ -129,13 +129,14 @@ not(2, 3)

### Expressions

Evaluates an expression that returns a boolean value. For example, [invoking a function](/docs/components/modeler/feel/language-guide/feel-functions#invocation).
When a unary operator is not enough to express the condition, any expression that returns a boolean value can be used,
such as [invoking a function](/components/modeler/feel/language-guide/feel-functions.md#invocation).

The input value can be accessed in the expression by using the symbol `?` (a question mark).
In the expression, the input value can be accessed by the special variable `?`.

```feel
contains(?, "good")
// check if the input value (string) contains "good"
// checks if the input value (string) contains "good"

ends with(?, "@camunda.com")
// checks if the input value (string) ends with "@camunda.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ string(date("2012-12-25"))

Parses the given string to a number.

Returns `null` if the string is not a number.

**Function signature**

```feel
Expand Down Expand Up @@ -72,6 +74,9 @@ context([{"key":"a", "value":1}, {"key":"b", "value":2}])

Returns a date from the given value.

Returns `null` if the string is not a valid calendar date. For example, `"2024-06-31"` is invalid because June has
only 30 days.

**Function signature**

```feel
Expand Down Expand Up @@ -100,6 +105,9 @@ date(date and time("2012-12-25T11:00:00"))

Returns a date from the given components.

Returns `null` if the components don't represent a valid calendar date. For example, `2024,6,31` is invalid because
June has only 30 days.

**Function signature**

```feel
Expand Down Expand Up @@ -179,6 +187,9 @@ time(14, 30, 0, duration("PT1H"))

Parses the given string into a date and time.

Returns `null` if the string is not a valid calendar date. For example, `"2024-06-31T10:00:00"` is invalid because
June has only 30 days.

**Function signature**

```feel
Expand Down
Loading
Loading