Skip to content

Commit 2e55c00

Browse files
committed
fix ternary expressions
1 parent 3cdf60d commit 2e55c00

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

guides/providing-services.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,7 @@ An `@assert` annotation may use other elements from the same entity. This annota
983983
```cds
984984
entity Order : cuid {
985985
986-
@assert: (? deliveryDate < orderDate
987-
: 'DELIVERY_BEFORE_ORDER')
986+
@assert: (deliveryDate < orderDate ? 'DELIVERY_BEFORE_ORDER' : null)
988987
items : Integer;
989988
}
990989
```
@@ -1006,8 +1005,8 @@ You can also perform validations based on entities associated via a to-many asso
10061005
```cds
10071006
entity Order : cuid {
10081007
1009-
@assert: (? exists items[book.isNotReleased = true]
1010-
: 'Some ordered book is not yet released')
1008+
@assert: (exists items[book.isNotReleased = true]
1009+
? 'Some ordered book is not yet released' : null)
10111010
items : Integer;
10121011
}
10131012
```
@@ -1018,7 +1017,7 @@ Refer to [Expressions as Annotation Values](../cds/cdl.md#expressions-as-annotat
10181017
Like other annotations, `@assert` is propagated to projections. If you annotate an element with `@assert` and the condition uses other elements - from the same or an associated entity - you must ensure that these elements are avaliable in all projections to which the annotated element is propagated. Otherwise the CDS model won't compile.
10191018

10201019
It is therefore recommended to use complex asserts on the highest projection, i.e. on the service layer.
1021-
:::s
1020+
:::
10221021

10231022
#### Multiple Conditions
10241023

0 commit comments

Comments
 (0)