Add lint rule for redundant protovalidate rules
Feature
There are situations where a protovalidate rule is redundant. For example, both rules in the following example express the same requirement: The field hello cannot be "":
syntax="proto3";
import "buf/validate/validate.proto";
message Message {
string hello = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.min_len = 1
];
}
// error raised for an empty field:
// hello: value is required [required]
It's similar for other standard rules:
syntax="proto3";
import "buf/validate/validate.proto";
message Message {
string email = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.email = true
];
}
// error raised for an empty field:
// email: value is required [required]
In this case, removing the required rule would actually produce a more helpful error:
email: value is empty, which is not a valid email address [string.email]
This applies to many of the standard rules on fields with implicit presence when combined with the required rule, but it depends on rule values.
buf lint could detect such situations, and alert the user about redundant rules. This leads to a more simple schema, and better error messages.
I would much prefer to get email: value is required than email: value is empty, which is not a valid email address. The former is a lot clearer as to what the problem is, the latter feels like a configuration error in validation. This also goes back to all of the stuff we've talked about w.r.t. how I have to do IGNORE_IF_ZERO_VALUE in a way.