Is there a way to check if a plain object is valid regarding to its protobuf message type ?
If I remember correctly, protobufjs v5 was doing so before encoding a message.
I didnt find a way to do it in protobufjs v6
Eg, given this proto :
syntax = "proto3";
package test;
message Foo {
string bar = 1;
}
const foo = root.lookup('test.Foo');
// should not throw
const validMessage = foo.create({ bar: 'foobar' });
// should throw an Error as 'xyz' is not a valid field
const invalidMessage = foo.create({ bar: 'foobar', xyz: 123 });
Is there a way to check if a plain object is valid regarding to its protobuf message type ?
If I remember correctly, protobufjs v5 was doing so before encoding a message.
I didnt find a way to do it in protobufjs v6
Eg, given this proto :