diff --git a/bookshop/srv/x-validation.cds b/bookshop/srv/x-validation.cds index 3ef7b696..c5f67ce1 100644 --- a/bookshop/srv/x-validation.cds +++ b/bookshop/srv/x-validation.cds @@ -8,8 +8,12 @@ using from '../db/schema'; view Books.constraints as select from Books { ID, // two-step mandatory check - title = null ? 'is missing' : trim(title)='' ? 'must not be empty' : - null as title, + case + when title is null then 'is missing' + when trim(title)='' then 'must not be empty' + end as title, + // the above is equivalent to: + // title is null ? 'is missing' : trim(title)='' ? 'must not be empty' : // range check stock < 0 ? 'must not be negative' :