You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validation has an ability to generate the code for implicitly required fields. Such fields are IDs of corresponding message types.
For example, a command message must have an ID, or an entity state must have an ID, and we do not want to force the user to apply (required)=true all the time. We want to make such rules assumed.
To support this feature we have the MessageMarkers type which allows to filter out message types into the following categories:
Entity states by using the repeated field entity_option_name.
Signal messages (commands, events, rejections) using the fields with FilePattern type.
McJava fills in MessageMarkers (as a part of ValidationConfig) from its settings when passing settings to ValidationPlugin executed by ProtoData.
The problem
The problem with this approach is that it breaks the level of abstraction. Validation should not know about entity states or signals. It's the job of Model Compilers, and McJava in particular.
Validation should have the notion of implicitly required fields and provide API for being informed about such fields from the tools that deal with custom message types. But it should not be organised via passing settings because:
It leaks the abstraction back to Validation.
Supporting more types requires extending MessageMarkers and therefore re-building Validation.
We need to resolve this issue and reduce the coupling between Validation and McJava. Fortunately, we already have the basis for such separation of abstractions: the abstract class RequiredIdPolicy. It has two descendants that handle entity states and signals. These descendants are RequiredIdOptionPolicy and RequiredIdPatternPolicy classes.
Suggested course of actions
Make RequiredIdPolicy public.
Make RequiredIdOptionPolicy a part of EntityPlugin in McJava. The policy would fire the events as it does now under Validation, but taking options directly from McJava.
Similarly to the item above, make RequiredIdPatternPolicy a part of SignalPlugin in McJava.
The text was updated successfully, but these errors were encountered:
Validation has an ability to generate the code for implicitly required fields. Such fields are IDs of corresponding message types.
For example, a command message must have an ID, or an entity state must have an ID, and we do not want to force the user to apply
(required)=true
all the time. We want to make such rules assumed.To support this feature we have the
MessageMarkers
type which allows to filter out message types into the following categories:entity_option_name
.FilePattern
type.McJava fills in
MessageMarkers
(as a part ofValidationConfig
) from its settings when passing settings toValidationPlugin
executed by ProtoData.The problem
The problem with this approach is that it breaks the level of abstraction. Validation should not know about entity states or signals. It's the job of Model Compilers, and McJava in particular.
Validation should have the notion of implicitly required fields and provide API for being informed about such fields from the tools that deal with custom message types. But it should not be organised via passing settings because:
MessageMarkers
and therefore re-building Validation.We need to resolve this issue and reduce the coupling between Validation and McJava. Fortunately, we already have the basis for such separation of abstractions: the abstract class
RequiredIdPolicy
. It has two descendants that handle entity states and signals. These descendants areRequiredIdOptionPolicy
andRequiredIdPatternPolicy
classes.Suggested course of actions
RequiredIdPolicy
public.RequiredIdOptionPolicy
a part ofEntityPlugin
in McJava. The policy would fire the events as it does now under Validation, but taking options directly from McJava.RequiredIdPatternPolicy
a part ofSignalPlugin
in McJava.The text was updated successfully, but these errors were encountered: