-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Labels
FeatureNew feature or requestNew feature or request
Description
Feature description:
Currently the value of the rule variable seems to only work with primitive types rather than custom messages
Works:
extend buf.validate.StringRules {
optional string allow = 536870909 [(buf.validate.predefined).cel = {
id: "string.identifier"
message: "field must be a valid identifier"
expression: "this == rule"
}];Does not work:
extend buf.validate.StringRules {
optional ComplexRule allow = 536870909 [(buf.validate.predefined).cel = {
id: "string.identifier"
message: "field must be a valid identifier"
expression: "rule.enabled && this == rule.value"
}];
message ComplexRule {
optional bool enabled = 1;
optional string value = 2;
}Problem it solves or use case:
This would allow more complex rules to be written in a cleaner fashion.
Proposed implementation or solution:
When the value of the predefined rule type is a proto message supply it as the value for rule.
Contribution:
I'm willing to attempt a PR if the maintainers don't have any deeper reason why this should not be allowed.
Metadata
Metadata
Assignees
Labels
FeatureNew feature or requestNew feature or request