mwitkow / go-proto-validators

Generate message validators from .proto annotations.
Apache License 2.0
1.08k stars 164 forks source link

Optional but if value exists apply this validation rule #53

Open neowulf opened 6 years ago

neowulf commented 6 years ago

Requesting to add the ability to add a validation rule to an optional field. I am unclear about the right syntax but a possible semantic would be like this:

// Optional. But if the value is present, the length of the value should be greater than 0
string fieldname = 1 [(validator.field) = {optional: true, length_gt: 0, length_lt: 257}];
chichunhua commented 3 years ago

Was this feature added? seems like the answer is NO?