mozy/ruby-protocol-buffers

valid? method should validate child messages when present

Closed this issue · 1 comments

consider:

message Foo {
required int32 id = 1;
optional Bar bar =2;
}

message Bar {
required int32 = 1;
}

f = Foo.new
f.id = 300
f.valid? # true (as expected)
b = Bar.new
f.bar = b
f.valid? #true (but should be false since f cannot be encoded)

Perhaps an alternative would be to indicate which message type failed validation when encoding.

Cheers

Yeah, valid? needs to modified to be recursive to sub-messages. Clearer encoding errors would be great too.