protoc-gen-validate
protoc-gen-validate copied to clipboard
Add CIDR validation for strings
This adds a new well known validation for strings which checks the input is a valid IP prefix in CIDR notation.
Example
message IPRoute {
string prefix = 1 [(validate.rules).string.cidr = true];
oneof egress {
string interface = 2;
string nexthop = 3 [(validate.rules).string.ip = true];
};
}
I added the validation to the Java code as well but I'm not a Java dev so it could be fine, or could be terrible. Hoping unit tests will pick up whether its at least functional but feedback on that point very welcome.
Ping @snowp is it possible to get this reviewed and hopefully merged?
Hi @ccakes, thanks for your contribution and your continued patience in this.
To get this over the line, I'd like to see a test... there are places for declaring test cases, e.g. for string const constraint: https://github.com/envoyproxy/protoc-gen-validate/blob/dc51e59d2e463996ef24e45621cf61f95fa64b0f/tests/harness/cases/strings.proto#L8 https://github.com/envoyproxy/protoc-gen-validate/blob/dc51e59d2e463996ef24e45621cf61f95fa64b0f/tests/harness/executor/cases.go#L739
You should be able to fit this into the relevant string tests in these directories.