Skip to content

Commit

Permalink
Merge 3ac45df into 46818d3
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-vr committed Jun 6, 2019
2 parents 46818d3 + 3ac45df commit 5dd7985
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/utils/data-construction.util.js
Expand Up @@ -25,6 +25,8 @@ function isFlatValue(val) {
}

function getValue(data, key, config, options) {
if (data[key] === null) return null;

if (config[key]) {
if (config[key] instanceof require('./../serializer')) { // eslint-disable-line global-require
return constructData(data[key], config[key].config, options);
Expand Down
9 changes: 8 additions & 1 deletion tests/nested-serializer.test.js
Expand Up @@ -58,16 +58,22 @@ describe('Nested serializer', () => {
country: 'Belgium',
},
],
contactInfo: null,
};

// serializer definition
const addressSerializer = new Serializer('address', {
attributes: ['street', 'number'],
});

const contactInfoSerializer = new Serializer('contactInfo', {
attributes: ['phoneNumber', 'email', 'skype']
})

const userSerializer = new Serializer('user', {
attributes: ['firstName', 'lastName', 'address'],
attributes: ['firstName', 'lastName', 'address', 'contactInfo'],
address: addressSerializer,
contactInfo: contactInfoSerializer,
});

const result = userSerializer.serialize(rawData);
Expand All @@ -86,6 +92,7 @@ describe('Nested serializer', () => {
number: '69',
},
],
contactInfo: null,
});
});
});

0 comments on commit 5dd7985

Please sign in to comment.