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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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