Skip to content

Why doesnt fromObject() fail for invalid enum values? #789

Open
@kostyay

Description

@kostyay

protobuf.js version: 6.7.3

If I use MyMessage.fromObject({'myEnum': 'invalid'}) I would expect the function to fail in case invalid is not one of the possible options for the enum. Current behavior just ignores the field and doesn't add anything into the resulting MyMessage instance.

enum MyEnum {
  VAL1 = 0;
  VAL2 = 1;
}

message MyMessage {
  string id = 1;
  MyEnum myEnum = 2;
}

MyMessage.fromObject({'myEnum': 'invalid', id: "22"}) // returns {id: "22"} which is valid

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions