Closed jinleileiking closed 6 years ago
@jinleileiking yes, you can customize message of field error by adding option into .proto file:
message CreateUserData {
string name = 1 [(validator.field) = {length_gt: 0 length_lt: 100 human_error: "User name is required and must be less than 100 chars length!"}];
}
So the final message will be "invalid field $MESSAGE_NAME.$FIELD_NAME: $text"
. But you can't remove this invalid field...
text.
@malyusha thanks for helping out here :)
If you want to strip the invalid field : bit, substr the errors in an interceptor or something :)
I can modify
return fmt.Errorf("validation error: InnerMessage.SomeFloat must be less than or equal to '1'")
by change the autogened file. But this is low. Any good way?