Skip to content

Conversation

danjoa
Copy link
Member

@danjoa danjoa commented Aug 20, 2025

Experimental Dynamic Constraints

This example demonstrates how to use dynamic constraints in a CAP application. It includes a service definition and a test setup to validate the constraints.

Prerequisites

You've setup the cap/samples like so:

git clone -b dynamic-constraints -q https://github.com/capire/samples cap/samples
cd cap/samples
npm install

Testing

Test like that in cds.repl from cap/samples root:

cds repl --run tests/dynamic-constraints
await AdminService.create ('Books', {})
await AdminService.create ('Books', { title:'   ', author_ID:150 })
await AdminService.create ('Books', { title:'x' })
await cds.validate (Books.constraints, 201)
await cds.validate (Books.constraints)
await AdminService.read `ID, title, price, fc.price from Books`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant