How to generate validator file only for message that contains validates rules ?
In the example below, actually sbt compilation generates 4 scala classes: one for protobufA, one for protobufB and one validator message for both.
int32 id = 1;
string action = 2 [(validate.rules).string = {in: ["tonic", "gin", "martini"]}];
}
message protobufB {
option (scalapb.message).annotations = "@JsonNaming(classOf[SnakeCaseStrategy])";
int32 id = 1;
string name = 2 ;
}
I would like to generate only three classes : one for protobufA, one for protobufB and the last for protobufA validator classes.
I have version 0.1.3 of scalapb-validate-codegen.
There is currently (as of version 0.2.1 of scalapb-validate) no way to suppress the generation of validation classes once you add the validation plugin. The only way, right now to do that would be to separate the messages you don't want to have validators for to separate SBT subprojects which doesn't have the validator plugin turned on.
Feel free to start a github issue on scalapb-validate github to discuss this as a feature request, and include also the motivation for a change like this. This would require some thought since messages that have validators require all the message that they transitively reference to have validators as well, so the plugin would have to detect this situation when disabling generation.