cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hello colleagues!


We are running a project on top NodeJS using CAP. We noticed a few weeks ago that the annotation @mandatory in the .cds file does not work for Function Modules.

I tested with the following annotations:

- @mandatory: https://cap.cloud.sap/docs/guides/generic#mandatory
- @FieldControl.Mandatory: https://cap.cloud.sap/docs/guides/generic#mandatory
- @Common.FieldControl.Mandatory:

None of them worked, so I'm not sure if they are supposed only to work with OData v2 or v4 API calls.

Here's a action in CDS as example:

action addGoal(
description : String(200) @mandatory,
targetCompletionDate : Timestamp @mandatory,
isPrivate : Boolean @mandatory );

In the example, we can add not null after the word Timestamp, and it becomes required. But for Strings as in description, adding not null wouldn't be enough to detect a blank string.

Do you know how to enable these annotations to work or if it's a known bug for CAP?


Thanks!

0 Likes
View Entire Topic
0 Likes

[Update]

I also tried using Annotations with the type, but this also didn't work for my case.

Example below

define type AdditionGoal {
  description          : String(200);
  targetCompletionDate : Timestamp;
  isPrivate            : Boolean;
}// Input validation
annotate AdditionGoal with {
  description             @mandatory;
  targetCompletionDate    @mandatory;
  isPrivate               @mandatory;
}
action addGoal(
    goal : AdditionGoal
  );

I passed to the backend an entity goal with the description property empty and CAP allowed it.