Skip to content
Open
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
14 changes: 8 additions & 6 deletions guides/services/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,15 @@ service Sue {
}
```

In addition to server-side input validation as introduced above, this adds a corresponding `@FieldControl` annotation to the EDMX so that OData / Fiori clients would enforce a valid entry, thereby avoiding unnecessary request roundtrips:
#### ... in Compositions
For insert/update, a mandatory value is **not** enforced when the property is missing from the request.
However, an explicitly provided `null/''` value is validated and rejected. This rule applies to compositions and cascading compositions. To enforce mandatory values, use the [`not null` constraint](../../cds/cdl#constraints) instead.

```xml
<Annotations Target="Sue.Books/title">
<Annotation Term="Common.FieldControl" EnumMember="Common.FieldControlType/Mandatory"/>
</Annotations>
```
#### ... in Associations

@johannes-vogel johannes-vogel Sep 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to repeat the section for associations. In associations, only the foreign key is respected. all other elements are not validated, it's not in particular specific for mandatory.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a previous version I had the impression that there was a notable change for associations:
image

If we'd remove the whole section about associations we'd loose the information about the not null constraint. Or should we move that somewhere else?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this sentence, for example, be moved to the general section?


For insert/update, a mandatory value is **not** enforced when the property is missing from the request. Even an explicitly provided `null/''` value is accepted. To enforce mandatory values, use the [`not null` constraint](../../cds/cdl#constraints) instead.
Comment thread
renejeglinsky marked this conversation as resolved.

[Learn more about `@Fieldcontrol` annotation with `@mandatory`.](#mandatory-1){.learn-more}

<div id="mandatorywithexpressions"/>

Expand Down
Loading