Hi everyone,

I'm trying to produce a specific response format and I'm struggling with 
the protobuf syntax to generate it. Worth mentioning, I'm new to protobuf 
and am struggling a bit with the docs, so it's likely that I missed 

The format I'm trying to produce, in json:

  success: false
  errors: {
    field1: ["error message 1", "error message 2"]
    field2: []

The proto syntax that I came up with looks like this:
message ResponseSubmit {
  bool success = 1
  map<string, ErrorList> errors = 2

message ErrorList {
  repeated string error = 1

Then, using the generated javascript libraries:

const response = new ResponseSubmit();
const errorsMap = response.getErrorsMap();
const valid = true;
const errors ={ field1: [], field2: ['Dummy error message'] };

response.setSuccess(valid); // this works ok

forEachObjIndexed((fieldErrors, fieldName) => {
  errorsMap.set(fieldName, fieldErrors); // this blows up 

Adding a field to the map via the set method crashes with a TypeError: 
b.toArray is not a function.

Can anyone lend a hand and point me to what I'm doing wrong here?

Thank you!


You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to