fuwaneko / node-protobuf

Google Protocol Buffers wrapper for Node.js [UNMAINTAINED]
179 stars 42 forks source link

Serializer should throw an exception when required fields are null #33

Closed elaberge closed 10 years ago

elaberge commented 10 years ago

Required nullable fields such as strings should throw an exception instead of being serialized as the "null" string.

it("Should throw an exception when required fields are null", function() {
    var objWithNull = {
        "name": null,
        "n64": 123
    }

    assert.throws(function() {
        var buffer = pb.serialize(objWithNull, "Test")
    }, Error)
})
fuwaneko commented 10 years ago

Yes, this is planned enhancement. Actually it will also throw if required field is not present at all.

fuwaneko commented 10 years ago

@elaberge missing required fields now throw an exception. Nulls too.