Required validation for scalar types
Problem
When I set up a required field for a scalar type, It is tedious to add "optional" and check for nil or empty every time. Currently, for example, in the case of "string", I set more than one character and apply validation.
Suggestion
I would like to see a simple mandatory validation implemented for scalar types.
Hi @Yuto2000, thanks for your interest. Could you help me out with some examples of what you do currently and how you believe the syntax could be improved?
Hi @elliotmjackson As shown below, I would like to see a simple required validation implemented.
optional string x = 1 [(validate.rules).string.required = true];
optional int32 x = 1 [(validate.rules).int32.required = true];
This feature would be very helpful.
Hi @Yuto2000 - in protovalidate we have implemented this on all fields. Updating your example...
optional string x = 1 [(buf.validate.field).required = true];
optional int32 y = 2 [(buf.validate.field).required = true];
A beta release for Go is available now we're working on C++, Java, TypeScript, and Python versions currently.