Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

same_as validation option #83

Open
alexander-yevsyukov opened this issue Mar 28, 2023 · 0 comments
Open

same_as validation option #83

alexander-yevsyukov opened this issue Mar 28, 2023 · 0 comments

Comments

@alexander-yevsyukov
Copy link
Collaborator

In some cases, especially when creating entity states, an ID field has a value which equals the value of a field of a nested message.

For example, in ProtoData, ProtobufSourceFile message has the ID field file_path, which has the same value as the path value of the nested File message contained in the file field:

message ProtobufSourceFile {
    option (entity).kind = VIEW;

    // The relative path to the file.
    //
    // Must be the same as `file.path`.
    //
    FilePath file_path = 1;

    File file = 2;
    ...
}

A programmer has to remember this fact, and currently there's no way to guard him against an error. It would be more convenient to have a validation option, which ensures that field values are equal:

message ProtobufSourceFile {
    option (entity).kind = VIEW;

    // The relative path to the file.
    //
    // Must be the same as `file.path`.
    //
    FilePath file_path = 1 [(same_as) = "file.path");

    File file = 2;
    ...
alexander-yevsyukov added a commit to SpineEventEngine/ProtoData that referenced this issue Nov 22, 2023
Ideally, we should do it via a validation option `(same_as)`. See [this issue](SpineEventEngine/validation#83) for details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant