Best way to restrict references? #360
-
Here is a grammar file I've simplified to demonstrate my problem...
I can create a Entity no problem and auo-completion works great for the supertype and for the keys.
The question is how to I modify the grammar so that the auto-suggestions for the keys that can be used in the Person entity is only the properties that are primitive types? At the moment, "id", "firstname", "surname" and "address" get auto suggested, but a key cannot be a complex object and so I do not want the "address" to be auto-suggested as a key? I'm missing something somewhere in my understanding of how to construct the grammar and possibly not try and do everything in the grammar itself and instead write validation rules? Not sure, any guidance would be great! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
There are multiple ways to solve that:
I recommend the third approach because it results in a much better error message to the users: Instead of "Could not resolve reference..." they will see something like "Only primitive types can be used as keys". |
Beta Was this translation helpful? Give feedback.
There are multiple ways to solve that:
Property
rule in two variants, one for primitive types and one for complex types, and use the primitive variant in the cross-reference (not recommended).ScopeProvider
service so it filters the properties to include only those with primitive types (not recommended).CompletionProvider
service to show only the properties with primitive type for that cross-reference.I recommend the third approach because it results in a much better error message to the users: Instead of "Could not resolve reference..." they will see somethi…