Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ serializer.buildKey = function (hashKey, rangeKey, schema) {

serializer.serializeItem = function (schema, item, options = {}) {
var serialize = function (value, datatypes = {}) {
if(!value) {
if(value === null) {
return null;
}

Expand Down
16 changes: 16 additions & 0 deletions test/serializer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,22 @@ describe('Serializer', function () {
item.objects.should.eql([{number: 10, string: 'd'}]);
});

it('should serialize number array with zeros', function () {
var config = {
hashKey: 'id',
schema : {
id : Joi.number(),
resolution : Joi.array().items(Joi.number()).min(2).max(2),
}
};

var s = new Schema(config);

var item = serializer.serializeItem(s, {id: 1, resolution: [0, 0]});

item.should.eql({id: 1, resolution: [0, 0]});
});

it('should return empty when serializing null value', function () {
var config = {
hashKey: 'email',
Expand Down