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

Support parentheses operator in required_field option #39

Open
yuri-sergiichuk opened this issue Mar 26, 2019 · 0 comments
Open

Support parentheses operator in required_field option #39

yuri-sergiichuk opened this issue Mar 26, 2019 · 0 comments

Comments

@yuri-sergiichuk
Copy link

yuri-sergiichuk commented Mar 26, 2019

In order to be able to specify the priority of the required_field logical operations explicitly, we should introduce support for the parentheses operator (()).

With such an operator it'll be possible to define such complex validation rules as e.g.:

message ComplexRequiredFields {

    option (required_field) = "(first | second) & (third | fourth) & fifth";

    repeated string first = 1;

    map<string,string> second = 2;

    oneof fields {
        string third = 3;
        string fourth = 4;
    }

    FifthField fifth = 5;

    message FifthField {
        string value = 1;
    }
}

In the message above we want the list or the map field and the oneof field and the message field to be required.

Without the parentheses operator, such a condition is just impossible to achieve. The following validation rule without parentheses will result in: first or second and third or fourth and fifth are required:

 option (required_field) = "first | second & third | fourth & fifth";

The notation above is actual equal to: "first | (second & third) | (fourth & fifth)".

@dmdashenkov dmdashenkov self-assigned this Nov 29, 2019
@alexander-yevsyukov alexander-yevsyukov transferred this issue from SpineEventEngine/base Sep 22, 2022
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

No branches or pull requests

2 participants