Skip to content

null as forced default value #39

Description

@nagarajanchinnasamy

For the below code:

var om = require('object-mapper');

var map = {
    "id": {
        "key": "destId",
        "transform": function(id) {
            return "_" + id;
        } // ,
        // "default": "0"
    }
};

var src = {
    // "id": 1
};

var dest = om(src, map);
console.log(JSON.stringify(dest));

As property id doesn't exist in src, I would expect an output of an empty object {}.

But the output generated is:

{ destId: '_null' }

The null value sent to transform is a wrongly forced default value.

I have made changes to fix this issue. However, it broke one of the tests (test no. 70) for which I have made changes to make it successful. Will send a pull request. Please review. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions