Skip to content

Support parentheses operator in required_field option #39

Closed
@yuri-sergiichuk

Description

@yuri-sergiichuk

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)".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions